in reply to mod_perl2 scope issue?
At least when you have a problem, stop hiding errors by using "use strict; use warnings;"!
mod_perl registry scripts are compiled inside as a sub:
sub { #!/usr/bin/perl use CGI; my $page = new CGI; print $page->header(); print "<html><head></head><body>"; print $page; print "<br>"; test(); print "</body></html>"; sub test{ print $page; } }
Patterns of the form
sub named_or_anon { my $x; sub named { ... $x ... } }
are bad. Perl even warns you about it.
$ perl -we' sub named_or_anon { my $x; sub named { $x } } ' Variable "$x" will not stay shared at -e line 6.
Don't use "global" my variables in registry scripts. Using local our $var instead of my $var should do the trick for "global" variables.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: mod_perl2 scope issue?
by Anonymous Monk on Jan 15, 2010 at 19:55 UTC |