A.2. The Apache::PerlRun Class
The Apache::PerlRun handler is intended for Perl CGI scripts that depend strongly on the traditional one-process-per-execution CGI model and cannot deal with being invoked repeatedly in the same process. For example, a script that depends on a lot of global variables being uninitialized when it starts up is unlikely to work properly under Apache::Registry.
Like Apache::Registry, Apache::PerlRun manages a directory of CGI scripts, launching them when they are requested. However, unlike Apache::Registry, this module does not cache compiled scripts between runs. A script is loaded and compiled freshly each time it is requested. However, Apache::PerlRun still avoids the overhead of starting a new Perl interpreter for each CGI script, so it's faster than traditional Perl CGI scripting but slower than Apache::Registry or vanilla Apache API modules. It offers a possible upgrade path for CGI scripts: move the script to Apache::PerlRun initially to get a modest performance bump. This gives you time to rework the script to make it globally clean so that it can run under Apache::Registry for the full performance benefit.
The configuration section for running Apache::PerlRun is similar to Apache::Registry :
Alias /perl-run/ /home/www/perl-run/ <Location /perl> SetHandler perl-script PerlHandler Apache::PerlRun Options +ExecCGI # optional PerlSendHeader On </Location>
The Apache::PerlRun handler is only a small part of the picture. The rest of the Apache::PerlRun ...
Get Writing Apache Modules with Perl and C now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.