Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
62 lines (51 sloc) 1.57 KB
__NAME__ purpose
define global Perl functions for use within Interchange
__NAME__ see also
__NAME__ synopsis
<arg choice='plain'>
__NAME__ description
Define a global subroutine for use within &tag-perl;, &tag-mvasp;, or
embedded &PERL; languages.
The use of "here document" syntax in &IC; makes subroutine definitions
visually convenient.
__NAME__ example: Defining a global subroutine
GlobalSub <<EOF
sub count_orders {
my $counter = new File::CounterFile "tmp/count_orders", '1';
my $number = $counter->inc();
return "There have been $number orders placed.\n";
The above code would be called from an &IC; page in the following way:
[perl tables=products subs='count_orders']
return count_orders();
__NAME__ notes
As with &PERL; "here documents," the "<literal>EOF</literal>" (or arbitrarily
named end marker) must be the <emphasis>only</emphasis> thing on the line,
without leading or trailing white space. Also, do not append a semicolon to the
opening marker (as you would in &PERL;).
Global subroutines are not subject to <classname>Safe</classname> security
checks. They can do most anything!
Therefore, &glos-scratch; or catalog subroutines (&conf-Sub;s) are
preferred in most cases to protect the innocent.
__NAME__ missing
Example isn't working? Sub gets called, but doesn't sort!
Jump to Line
Something went wrong with that request. Please try again.