perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Adam Prime <>
Subject Re: lexical scoping under mod perl solution
Date Thu, 12 Feb 2009 16:12:53 GMT
Erik Aronesty wrote:
> (A solution would be to force all "my" varialbes at the file scope to
> be "our" and then put the cgi in an anonymous package:)
> On Thu, Feb 12, 2009 at 10:33 AM, Erik Aronesty <> wrote:
>> -------------8<---------- Start Bug Report ------------8<----------
>> 1. Problem Description:
>> It's well known that file-scoped lexicals don't work intuitively in
>> CGI programs under mod_perl.
>> When mod_perl calls the same CGI program twice, file-scoped lexicals
>> are not rebound.
>> Some people are aware of this, random posts to newsgroups will attest,
>> but this is not documented well enough.
>> Create a CGI as below, and run it many times, assigning different
>> CGI::param('foo') values to $x.
>> Lowering the number of children spawned in Apache will reduce the
>> number of times needed
>> to run the script in order to see the problem.
>> # this program sometimes prints old values for foo, but only under mod_perl!
>>  use CGI;
>>  my $x =CGI::param('foo');

I assume that you're running under ModPerl::Registry, since you haven't 
specified otherwise, is that actually the case?  If it is, I'd encourage 
you to try running under ModPerl::PerlRun instead, which does a better 
job of emulating CGI (at the expense of speed).

You are absolutely right though that this should be explicitly noted in 
the documentation for Registry (and possibly PerlRun, if it doesn't work 
there either).  I personally very rarely use CGI emulation, so i'm not 
entirely sure what does and doesn't work.


View raw message