in reply to Re: Variable will not stay shared in a sporadically crashing CGI
in thread Variable will not stay shared in a sporadically crashing CGI
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Variable will not stay shared in a sporadically crashing CGI
by haukex (Archbishop) on Oct 02, 2017 at 13:38 UTC | |
by LanX (Saint) on Oct 02, 2017 at 14:02 UTC | |
by Anonymous Monk on Oct 02, 2017 at 13:48 UTC | |
by haukex (Archbishop) on Oct 02, 2017 at 13:53 UTC |