URIs in the form of http://example.com/perl/test.pl will be
compiled as the body of a Perl subroutine and executed. Each child
process will compile the subroutine once and store it in memory. It
will recompile it whenever the file (e.g. test.pl in our example)
is updated on disk. Think of it as an object oriented server with
each script implementing a class loaded at runtime.
The file looks much like a normal script, but it is compiled into a
my $r = Apache2::RequestUtil->request;
XXX: STOPPED here. Below is the old Apache::Registry document which I
havent worked through yet.
META: document that for now we dont chdir() into the scripts dir,
because it affects the whole process under
should be used by those who run only under prefork MPM.
This module emulates the CGI environment, allowing programmers to
write scripts that run under CGI or mod_perl without change. Existing
CGI scripts may require some changes, simply because a CGI script has
a very short lifetime of one HTTP request, allowing you to get away
with quick and dirty scripting. Using mod_perl and ModPerl::Registry
requires you to be more careful, but it also gives new meaning to the
Be sure to read all mod_perl related documentation for more details,
including instructions for setting up an environment that looks
exactly like CGI:
print "Content-type: text/html\n\n";
print "Hi There!";
Note that each httpd process or child must compile each script once,
so the first request to one server may seem slow, but each request
there after will be faster. If your scripts are large and/or make use
of many Perl modules, this difference should be noticeable to the
Normally when a Perl script is run from the command line or under CGI,
arguments on the #! line are passed to the perl interpreter for processing.
ModPerl::Registry currently only honors the <B>-wB> switch and will
enable the warnings pragma in such case.
Another common switch used with CGI scripts is <B>-TB> to turn on taint
checking. This can only be enabled when the server starts with the
However, if taint checking is not enabled, but the <B>-TB> switch is
seen, ModPerl::Registry will write a warning to the error_log