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



Reply via email to