Apache resp. mod_perl is wrapping your CGI script in a subroutine to repeatedly call it.This is the right explanation, but maybe the meaning is not completely clear. When you use Apache::Registry to run your script, it literally adds a set of brackets around your script and makes the whole thing into a sub, kind of like this:
sub handler { #!/usr/bin/perl use strict; use warnings; use CGI; my $cgi = new CGI; print_document_header(); sub print_document_header { print $cgi->header( -type => 'text/html' ), "\n"; } }
Your workaround of explicitly passing around the variable is a good one in my opinion.I completely agree, but if you're allergic to good programming practice you can just use our $cgi instead of my $cgi.
In reply to Re^2: Variable will not stay shared in a sporadically crashing CGI
by Anonymous Monk
in thread Variable will not stay shared in a sporadically crashing CGI
by Locutus
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |