Your CGI script is called often, and the web server is suffering as a result. You'd like to lessen the load your CGI script causes.
Alias /perl/ /real/path/to/perl/scripts/ <Location /perl> SetHandler perl-script PerlHandler Apache::Registry Options ExecCGI </Location> PerlModule Apache::Registry PerlModule CGI PerlSendHeader On
mod_perl Apache web server module, you can write Perl code that will step in at any part of a request's processing. You can write your own logging and authentication routines, define virtual hosts and their configuration, and write your own handlers for certain types of request.
The snippet above says that requests with URLs starting in /perl/ are actually in /real/path/to/perl/scripts/ and that they should be handled by Apache::Registry. This runs them in a CGI environment.
CGI preloads the CGI module, and
On makes most of your CGI scripts work out of the box with
/perl/ works analogously to /cgi-bin/. To make the suffix .perl indicate
mod_perl CGI scripts just as the suffix .cgi indicates regular CGI scripts, use the following in your Apache configuration file:
<Files *.perl> SetHandler perl-script PerlHandler Apache::Registry Options ExecCGI </Files>
Because the Perl interpreter that runs your CGI script doesn't shut down when your script is done (as normally happens when the web server runs your script as a separate program), you cannot rely on your global variables being undefined when the program starts. -w and
strict check for many bad habits in these kinds of scripts. There are other gotchas, too - see the mod_perl_traps manpage.
Don't worry about how big your web server processes appear to grow from pre-loading all these scripts. They need to find their way into memory eventually, and it's better to happen before Apache forks off kids. That way each script has to be in memory only once, because forked children have shared memory pages (under all modern operating systems). In other words, it only appears to take up more memory this way. It actually takes less!