Re: WELCOME to modperl@perl.apache.org

Re: WELCOME to modperl@perl.apache.org

am 12.02.2009 18:53:33 von earonesty

> Maybe ModPerl::Registry should do this, but not mod_perl itself. If someone

Yes, it's a problem with ModPerl::Registry, I agree. It's not mentioned here:

http://perl.apache.org/docs/2.0/api/ModPerl/Registry.html#Ca veats

Where it should be.

> is trying to get an old CGI script to work under mod_perl then they'd use
> Registry. But there's no reason to make the rest of us suffer for their old
> scripts.

# This isn't an "old" program...it's a simple program,
# and no amount of "strict or warnings" will help debug it

use CGI;
my $x =CGI::param('foo');

&y;

sub y {
print "content-type:text/plain\n\n?$x\n";
}

Re: WELCOME to modperl@perl.apache.org

am 12.02.2009 19:58:35 von Adam Prime

Erik Aronesty wrote:
>> Maybe ModPerl::Registry should do this, but not mod_perl itself. If someone
>
> Yes, it's a problem with ModPerl::Registry, I agree. It's not mentioned here:
>
> http://perl.apache.org/docs/2.0/api/ModPerl/Registry.html#Ca veats
>
> Where it should be.

Absolutely, i'll patch the docs to add a link to the perl reference page
over the weekend.

>> is trying to get an old CGI script to work under mod_perl then they'd use
>> Registry. But there's no reason to make the rest of us suffer for their old
>> scripts.
>
> # This isn't an "old" program...it's a simple program,
> # and no amount of "strict or warnings" will help debug it
>
> use CGI;
> my $x =CGI::param('foo');
>
> &y;
>
> sub y {
> print "content-type:text/plain\n\n?$x\n";
> }

If you add use strict and use warnings to that script, you get this in
your error_log:

Variable "$x" will not stay shared at /usr/local/prefork/perl/thing.cgi
line 10.

which, with a quick googling of 'mod_perl variable will not stay
shared', turns you to a number of resources talking about the problem,
and it's solutions.

And for what it's worth, it seems that running under ModPerl::PerlRun
makes it work alright, albeit with 2 warnings in the error_log:

Variable "$x" will not stay shared at /usr/local/prefork/perl/haha.cgi
line 10.
Subroutine y redefined at /usr/local/prefork/perl/haha.cgi line 9.

Adam