[prev in list] [next in list] [prev in thread] [next in thread] 

List:       apache-modperl
Subject:    Re: Precomiling CGI.pm and remembered values
From:       "Will Stranathan" <pangzi74 () hotmail ! com>
Date:       2004-01-29 12:56:45
Message-ID: Law11-F75x8dyDd3OJX000171d8 () hotmail ! com
[Download RAW message or body]

Well, I did as you said, but the problem still seems to be with when I 
preload CGI in a startup script - the problem goes away when I don't 
precompile.

See below.

>
>Will Stranathan wrote:
>
>>I've looked at the mod_perl documentation on how to eliminate the problem 
>>of values being remembered when a named inner subroutine accesses a 
>>lexical symbol.  I *thought* I was doing things correctly, but when I 
>>precompile (or even preload) CGI, I get the same types of problems, 
>>regardless.
>
>Looks to me like the problem is not about CGI, but about the way you are 
>using lexical variables.  You have created two closures.
>
>>My/Form.pm:
>>package My::Form;
>>use strict;
>>use CGI;
>>use base 'Exporter';
>>our @EXPORT = 'dojob';
>>
>>my $foo;
>>my $q;
>
>Get rid of those two lines.  They are turning the other subs into closures.
>

What I thought...

>
>>sub dojob {
>>     my $q = new CGI;
>>     $foo = $q->param('foo');
>>     print "Content-type: text/html\n\n";
>>     do_work($foo);
>>}
>
>That will be fine, once you remove the declaration of $q above.  You should 
>be seeing a warning in your logs about this ($q masks earlier variable...). 
>  Turn on warnings, if you haven't already.
>

PerlSwitches -wT is on, and I've even gone so far as to take $foo out of the 
picture.  To simplify and show the point, I now have

sub dojob {
	my $cgiquery = new CGI;
	print "Content-type: text/html\n\n";
	print "<html><body><form><input type=\"text\" name=\"foo\" value=\""
		. $cgiquery->param('foo')
		. "\"><br><input type=\"submit\"></form></body></html>";
}

and still get the same problem.

No warnings show in the log, and I can make the problem go away by simply 
removing use CGI; from the startup script.

This happens with CGI.pm 2.91 and 3.01

_________________________________________________________________
Check out the new MSN 9 Dial-up — fast & reliable Internet access with prime 
features! http://join.msn.com/?pgmarket=en-us&page=dialup/home&ST=1


-- 
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic