CGI::Compile(3) User Contributed Perl Documentation CGI::Compile(3)NAMECGI::Compile - Compile .cgi scripts to a code reference like
ModPerl::Registry
SYNOPSIS
use CGI::Compile;
my $sub = CGI::Compile->compile("/path/to/script.cgi");
DESCRIPTIONCGI::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.
RUN ON PSGI
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
CAVEATS
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 "my" with "our". See also
<http://perl.apache.org/docs/1.0/guide/porting.html#The_First_Mystery>
for more details.
AUTHOR
Tatsuhiko Miyagawa <miyagawa@bulknews.net>
CONTRIBUTORS
Rafael Kitover <rkitover@cpan.org>
Hans Dieter Pearcey <hdp@cpan.org>
COPYRIGHT & LICENSE
Copyright (c) 2009 Tatsuhiko Miyagawa <miyagawa@bulknews.net>
This library is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
SEE ALSO
ModPerl::RegistryCooker CGI::Emulate::PSGI
perl v5.14.1 2011-05-24 CGI::Compile(3)