web-iPerl - bring Web-documents alive with bits of embedded Perl
This is the webserver frontend of an inverse Perl interpreter, where HTML, XML, SGML, PostScript or plain text gets passed to the browser as is, while specially marked Perl statements are executed on the server-side. Loop or conditional blocks can surround normal text. The MIME-type is recognized by the file suffix according to the following table:
html, phtml, htmlp and pht, htp
html
phtml
htmlp
pht
htp
css, pcss, cssp and pcs, csp
css
pcss
cssp
pcs
csp
All not found elsewhere, including txt, ptxt, txtp and ptx, txp
txt
ptxt
txtp
ptx
txp
utxt, putxt, utxtp and put, utp
utxt
putxt
utxtp
put
utp
sgml, psgml, sgmlp and psg, sgp
sgml
psgml
sgmlp
psg
sgp
wml, pwml, wmlp and pwm, wmp
wml
pwml
wmlp
pwm
wmp
xml, pxml, xmlp and pxm, xmp
xml
pxml
xmlp
pxm
xmp
ps, pps, psp, eps, peps, epsp and pep, epp
ps
pps
psp
eps
peps
epsp
pep
epp
xbm, pxbm, xbmp and pxb, xbp
xbm
pxbm
xbmp
pxb
xbp
xpm, pxpm, xpmp and pxp, xpp (not understood by most browsers)
xpm
pxpm
xpmp
pxp
xpp
The first plain text flushed out by web-iPerl is preceded by the value $header, which has been set for you. This means that if your document starts with a bit of Perl, the variable contains the HTTP-header and may be modified. Or you can unset it and write the header right after the Perl section - no newline in between though! Inversely you should not print any output before the header has been printed. Processing occurs in the directory where the file was found.
web-iPerl
$header
print
If you call any system-commands (beware of passing uncontrolled arguments from the query!) you should first turn on autoflushing ($| = 1) to ensure that output order is preserved.
$| = 1
Normally the empty string. Is output and reset every time iPerl wants to output a bit of plain text.
Holds the list of arguments to CGI function header. This can help you change the header more easily, by adding you own options.
$header = header @type, ...;
The file-suffixes are freely electable as listed above. For Apache these are attributed to an internal MIME-type, which is then correlated to the web-iPerl interpreter by the action module, which must be installed in Apache. On these lines, which are the same for the three following alternatives, put all the suffixes you expect to use among those found above, under DESCRIPTION:
AddType application/x-web-iPerl pcss phtml pps ptxt putxt pps DirectoryIndex index.html index.htm index.phtml index.pht
The installation depends on what you have, and what you want:
If you have mod_perl installed (which you should for remarkable performance gains!), this is the necessary configuration. The first part is possibly already done for you.
<Location /perl/> SetHandler perl-script PerlHandler Apache::Registry Options ExecCGI PerlSendHeader On </Location>
You must copy web-iperl to the perl-directory in your web-server tree. Then you add the following line to your configuration:
Action application/x-web-iPerl /perl/web-iPerl
This is the classical mode of operation. You must copy web-iperl to the cgi-bin-directory in your web-server tree, which we assume to have been set up. Then you add the following line to your configuration:
Action application/x-web-iPerl /cgi-bin/web-iPerl
Warning: Due to the way the CGI mechanism works, this method can cause failure when running under full load. If the server already has as many processes running as one user is allowed by the system to spawn, starting this script will fail, making some page temporarily inservable. This means that the MAXUP kernel parameter should be somewhat higher than the maximum number of connections served.
This is another classical mode of operation. Unlike the preceding one, the server doesn't look at your output. The header funtion takes this into account by adding a HTTP-response line. On the downside, you yourself are responsible for everything else you want, like keep-alive negotiation.
header
You must copy web-iperl to the cgi-bin-directory in your web-server tree, which we assume to have been set up, and rename (as hard-wired in Apache) it to nph-iperl. Then you add the following line to your configuration:
Action application/x-web-iPerl /cgi-bin/nph-iPerl
Warning: Same as for CGI, just above.
Text::iPerl, iperl, iPerl.el, perl, apache, mod_perl, http://beam.to/iPerl/
To install Text::iPerl, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Text::iPerl
CPAN shell
perl -MCPAN -e shell install Text::iPerl
For more information on module installation, please visit the detailed CPAN module installation guide.