More about Perl and CGIplus


Perl is a powerful language and should be used to greater advantage. Unfortunately in a CGI context the overheads of starting Perl (particularly under VMS) can severly impact request response time and system overhead.

WASD's persistant scripting environment (CGIplus) can mean a script needs to be started only occasionally, stays resident servicing multiple requests, until idle for a specified period at which time it terminates. For detailed information on CGIplus see WASD Scripting Environment. Just compare the latency difference between the CGI and CGIplus usage (after the first access) of exactly the same script.

script:  CGIplusPM_example1.pl
CGI:  /cgi-bin/CGIplusPM_example1
CGIplus:  /cgiplus-bin/CGIplusPM_example1   [restart]

Benchmarking this using ApacheBench on the author's development system indicated 0.3 and 6.9 requests/second for the CGI and CGIplus usages respectively.  Expressed another way, the CGIplus usage responded 20 times faster!  Remember this is the same script - no changes apart from invocation path.

CGIplus.pm

The CGIplus.pm Perl module is intended to assist script authors write scripts that may be used transparently in both vanilla CGI environments (including non-WASD) as well as under WASD CGIplus. The only essential difference between CGI and CGIplus is the mechanism for deriving the CGI variables, everything else is exactly the same as plain-old CGI.

The module also compensates for variations in VMS environments. Most VMS CGI environments provide their CGI variables via DCL symbols. Many Perl scripts access these via the %ENV array. Some VMS Perl versions do not support DCL symbols via this mechanism. CGIplus.pm detects whether CGI variables are available via %ENV and if not attempts to use Charles Bailey's VMS::DCLsym extension module built into most versions of VMS Perl.

In summary the module transparently makes CGI variables available for most VMS Perl CGI environments, as well as for WASD's persistant CGIplus.

Binary Responses

VMS' RMS complicates output streams under Perl. This is a particular issue with CGIplus end-of-file sentinals, which must be output as a single record. CGIplus.pm attempts to provide a simple mechanism for providing binary streams if necessary, while still ensuring it's own records are not interfered with. This uses Charles Bailey's VMS::Stdio extension module built into most versions of VMS Perl.

This script demonstrates how the modules stream functions can be directly used.

script:  CGIplusPM_example2.pl
CGI:  /cgi-bin/CGIplusPM_example2
CGIplus:  /cgiplus-bin/CGIplusPM_example2   [restart]

This script demonstrates how to simply return a binary file as a response.

script:  CGIplusPM_example3.pl
CGI:  /cgi-bin/CGIplusPM_example3
CGIplus:  /cgiplus-bin/CGIplusPM_example3   [restart]

Any accessable image location may be added to these scripts following the script part. Again, because these are being accessed via a CGIplus script, notice the difference in latency between the initial and subsequent requests.


Last Revised May 2000