The Perl language environment can interpret inline Perl scripts that you specify in a FUNCTION block of the Net.Data macro, or it can process external Perl scripts that are stored in separate files on the server. Calls to external Perl scripts are identified in a FUNCTION block by an EXEC statement, for example:
%EXEC{ perl-script-name [optional parameters] %}
The Perl language environment cannot directly pass or retrieve Net.Data variables, so they are made available to Perl scripts in this manner:
name = value
For multiple data items, separate each item with a new-line or blank character.
If a variable name has the same name as an output parameter and uses the above syntax, the new value replaces the current value. If a variable name does not correspond to an output parameter, Net.Data ignores it.
The following example shows how Net.Data passes variables from a macro file.
%FUNCTION(DTW_PERL) today() RETURNS(result) {
$date = `date`;
chop $date;
open(DTW, "> $ENV{DTWPIPE}") || die "Could not open: $!";
print DTW "result = \"$date\"\n";
%}
%HTML(INPUT) {
@today()
%}
If the Perl script is in an external file called today.prl, the same function can be written as in the next example:
%FUNCTION(DTW_PERL) today() RETURNS(result) {
%EXEC { today.prl %}
%}
A Perl language environment program accesses the values of a table parameter by their Net.Data name. The column headings for table T are T_N_i, and the field values are T_V_i_j. The number of rows and columns in table T are T_ROWS and T_COLS.
REPORT and MESSAGE blocks are permitted as in any FUNCTION section. They are processed by Net.Data, not by the language environment. A Perl program can, however, write text to the standard output stream and directly manipulate the output HTML form.
Authorization Tip: Ensure that the user ID under which Net.Data executes has access rights to any external executable files referenced by this language environment, including the correct version of the Perl interpreter. See the section on specifying Web server access rights to Net.Data files in the configuration chapter of Net.Data Administration and Programming Guide for more information.