docs::api::ModPerl::Registry - Online Linux Manual PageSection : 3
Updated : 2021-01-26
Source : perl v5.32.1
Note : User Contributed Perl Documentation

NAMEModPerl::Registry − Run unaltered CGI scripts persistently under mod_perl

Synopsis​ # 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>

DescriptionURIs 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−>send_http_header; ​ $r−>print("mod_perl rules!"); XXX: STOPPED here. Below is the old Apache::Registry document which I haven't worked through yet. META: document that for now we don't chdir() into the script's dir, because it affects the whole process under threads. ModPerl::RegistryPrefork 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 word quick! 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 human eye.

DirectoryIndexIf you are trying setup a DirectoryIndex under a Location covered by ModPerl::Registry* you might run into some trouble. META: if this gets added to core, replace with real documenation. See http://marc.theaimsgroup.com/?l=apache−modperl&m=112805393100758&w=2

Special Blocks

BEGIN BlocksBEGIN 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 BlocksSame as normal mod_perl handlers.

END BlocksEND 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.

SecurityModPerl::Registry::handler performs the same sanity checks as mod_cgi does, before running the script.

EnvironmentThe Apache function `exit' overrides the Perl core built-in function.

Commandline Switches In First LineNormally 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 −w switch and will enable the warnings pragma in such case. Another common switch used with CGI scripts is −T to turn on taint checking. This can only be enabled when the server starts with the configuration directive: ​ 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.

DebuggingYou 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

CaveatsModPerl::Registry makes things look just the CGI environment, however, you must understand that this *is not CGI*. Each httpd child will compile your script into memory and keep it there, whereas CGI will run it once, cleaning out the entire process space. Many times you have heard "always use −w, always use −w and 'use strict'". This is more important here than anywhere else! Some other important caveats to keep in mind are discussed on the Perl Reference page.

AuthorsAndreas J. Koenig, Doug MacEachern and Stas Bekman.

See AlsoModPerl::RegistryCooker, ​ModPerl::RegistryBB and ​ModPerl::PerlRun.
0
Johanes Gumabo
Data Size   :   17,248 byte
man-ModPerl::Registry.3pmBuild   :   2024-12-05, 20:55   :  
Visitor Screen   :   x
Visitor Counter ( page / site )   :   5 / 169,423
Visitor ID   :     :  
Visitor IP   :   3.147.54.100   :  
Visitor Provider   :   AMAZON-02   :  
Provider Position ( lat x lon )   :   39.962500 x -83.006100   :   x
Provider Accuracy Radius ( km )   :   1000   :  
Provider City   :   Columbus   :  
Provider Province   :   Ohio ,   :   ,
Provider Country   :   United States   :  
Provider Continent   :   North America   :  
Visitor Recorder   :   Version   :  
Visitor Recorder   :   Library   :  
Online Linux Manual Page   :   Version   :   Online Linux Manual Page - Fedora.40 - march=x86-64 - mtune=generic - 24.12.05
Online Linux Manual Page   :   Library   :   lib_c - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Online Linux Manual Page   :   Library   :   lib_m - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Data Base   :   Version   :   Online Linux Manual Page Database - 24.04.13 - march=x86-64 - mtune=generic - fedora-38
Data Base   :   Library   :   lib_c - 23.02.07 - march=x86-64 - mtune=generic - fedora.36

Very long time ago, I have the best tutor, Wenzel Svojanovsky . If someone knows the email address of Wenzel Svojanovsky , please send an email to johanes_gumabo@yahoo.co.id .
If error, please print screen and send to johanes_gumabo@yahoo.co.id
Under development. Support me via PayPal.

ERROR : Need New Coding :         (parse_manual_page_|249|ModPerl::Registry.3pm|36/37|el══─{─══.|.el══─{─══. ds -- \|\(em\| )         (htmlprn|149|ModPerl::Registry.3pm|36/37|.el══─{─══. ds --  —  |.el══─{─══. ds -- \|\(em\| )         (parse_manual_page_|249|ModPerl::Registry.3pm|43|br══─}─══|'br══─}─══ )         (htmlprn|149|ModPerl::Registry.3pm|43|'br══─}─══ |'br══─}─══ )