CGI::Compile - Compile .cgi scripts to a code reference like ModPerl::Registry
use CGI::Compile; my $sub = CGI::Compile->compile("/path/to/script.cgi");
CGI::Compile is an utility to compile CGI scripts into a code reference that can run many times on its own namespace, as long as the script is ready to run on a persistent environment.
NOTE: for best results, load CGI::Compile before any modules used by your CGIs.
Combined with CGI::Emulate::PSGI, your CGI script can be turned into a persistent PSGI application like:
use CGI::Emulate::PSGI; use CGI::Compile; my $cgi_script = "/path/to/foo.cgi"; my $sub = CGI::Compile->compile($cgi_script); my $app = CGI::Emulate::PSGI->handler($sub); # $app is a PSGI application
If your CGI script has a subroutine that references the lexical scope variable outside the subroutine, you'll see warnings such as:
Variable "$q" is not available at ... Variable "$counter" will not stay shared at ...
This is due to the way this module compiles the whole script into a big
sub. To solve this, you have to update your code to pass around the lexical variables, or replace
our. See also http://perl.apache.org/docs/1.0/guide/porting.html#The_First_Mystery for more details.
Tatsuhiko Miyagawa <firstname.lastname@example.org>
Rafael Kitover <email@example.com>
Hans Dieter Pearcey <firstname.lastname@example.org>
Copyright (c) 2009 Tatsuhiko Miyagawa <email@example.com>