Optional, package to install the script into, defaults to the path parts of the script joined with _, and all special characters converted to _%2x, prepended with CGI::Compile::ROOT::.
$cgi_script or $$code compiled to coderef.
Things like the query string and form data should generally be in the appropriate environment variables that things like CGI expect.
You can also pass arguments to the generated coderef, they will be locally aliased to @_ and @ARGV.
CWBEGIN and CWEND blocksBEGIN blocks are called once when the script is compiled. END blocks are called when the Perl interpreter is unloaded.
This may cause surprising effects. Suppose, for instance, a script that runs in a forking web server and is loaded in the parent process. END blocks will be called once for each worker process and another time for the parent process while BEGIN blocks are called only by the parent process.
CW%SIGThe %SIG hash is preserved meaning the script can change signal handlers at will. The next invocation gets a pristine %SIG again.
CWexit and exceptionsCalls to exit are intercepted and converted into exceptions. When the script calls exit 19 and exception is thrown and $@ contains a reference pointing to the array
$CGI::Compile::USE_REAL_EXIT = 1; exit 19;
Other exceptions are propagated out of the generated coderef. The coderefs caller is responsible to catch them or the process will exit.
The generated coderefs exit value is either the parameter that was passed to exit or the value of the last statement of the script. The return code is converted into an integer.
On a 0 exit, the coderef will return 0.
On an explicit non-zero exit, by default an exception will be thrown of the form:
exited nonzero: <n>
where n is the exit value.
This only happens for an actual call to exit in perfunc, not if the last statement value is non-zero, which will just be returned from the coderef.
If you would prefer that explicit non-zero exit values are returned, rather than thrown, pass:
return_exit_val => 1
in your call to new.
Alternately, you can change this behavior globally by setting:
$CGI::Compile::RETURN_EXIT_VAL = 1;
If CGI::Compile->compile was passed a script file, the scripts directory becomes the current working directory during the runtime of the script.
NOTE: to be able to switch back to the original directory, the compiled coderef must establish the current working directory. This operation may cause an additional flush operation on file handles.
CWSTDIN and CWSTDOUTThese file handles are not touched by CGI::Compile.
The CWDATA file handleIf the script reads from the DATA file handle, it reads the __DATA__ section provided by the script just as a normal script would do. Note, however, that the file handle is a memory handle. So, fileno DATA will return -1.
If the subroutine CGI::initialize_globals is defined at script runtime, it is called first thing by the compiled coderef.
Tatsuhiko Miyagawa <email@example.com>
Rafael Kitover <firstname.lastname@example.org>
Hans Dieter Pearcey <email@example.com>
Torsten Foertsch <firstname.lastname@example.org>
Copyright (c) 2009 Tatsuhiko Miyagawa <email@example.com>
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
|perl v5.20.3||CGI::COMPILE (3)||2015-03-06|