ModPerl::Registry (3)
Leading comments
Automatically generated by Pod::Man 4.09 (Pod::Simple 3.35) Standard preamble: ========================================================================
NAME
ModPerl::Registry - Run unaltered CGI scripts persistently under mod_perlSynopsis
# httpd.conf PerlModule ModPerl::Registry Alias /perl/ /home/httpd/perl/ <Location /perl> SetHandler perl-script PerlResponseHandler ModPerl::Registry #PerlOptions +ParseHeaders #PerlOptions -GlobalRequest Options +ExecCGI </Location>
Description
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 subroutine.
For example:
my $r = Apache2::RequestUtil->request; $r->content_type("text/html"); $r->print("mod_perl rules!");
This module emulates the
Be sure to read all mod_perl related documentation for more details, including instructions for setting up an environment that looks exactly like
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 human eye.
DirectoryIndex
If you are trying setup a DirectoryIndex under a Location covered by ModPerl::Registry* you might run into some trouble.
Special Blocks
BEGIN Blocks
"BEGIN" blocks defined in scripts running under the "ModPerl::Registry" handler behave similarly to the normal mod_perl handlers plus:- *
- Only once, if pulled in by the parent process via "Apache2::RegistryLoader".
- *
- An additional time, once per child process or Perl interpreter, each time the script file changes on disk.
"BEGIN" blocks defined in modules loaded from "ModPerl::Registry" scripts behave identically to the normal mod_perl handlers, regardless of whether they define a package or not.
CHECK and INIT Blocks
Same as normal mod_perl handlers.END Blocks
"END" blocks encountered during compilation of a script, are called after the script has completed its run, including subsequent invocations when the script is cached in memory. This is assuming that the script itself doesn't define a package on its own. If the script defines its own package, the "END" blocks in the scope of that package will be executed at the end of the interpretor's life."END" blocks residing in modules loaded by registry script will be executed only once, when the interpreter exits.
Security
"ModPerl::Registry::handler" performs the same sanity checks as mod_cgi does, before running the script.Environment
The Apache function `exit' overrides the Perl core built-in function.Commandline Switches In First Line
Normally when a Perl script is run from the command line or under"ModPerl::Registry" currently only honors the -w switch and will enable the "warnings" pragma in such case.
Another common switch used with
PerlSwitches -T
However, if taint checking is not enabled, but the -T switch is seen, "ModPerl::Registry" will write a warning to the error_log file.
Debugging
You may set the debug level with the $ModPerl::Registry::Debug bitmask
1 => log recompile in errorlog 2 => ModPerl::Debug::dump in case of $@ 4 => trace pedantically