[ also posted on PerlMonks ]

I'm working on porting some code that's been running on mod_perl 1 for
a very long time to mod_perl 2. Mostly things have gone smoothly, but
I'm having trouble with environment variables. Sometimes my scripts go
off and run other scripts, and expect to be able to set things like
$ENV{PATH} for the child processes. However, for some reason under
mod_perl 2, my environment variables aren't getting passed to child
processes! Quite bizarre.

Here's an example:

    #!/usr/bin/perl -T
    
    use strict;
    use warnings;
    
    print "Content-type: text/plain\n\n";
    
    $ENV{PATH}="/usr/bin";
    
    print "PARENT: PATH is $ENV{PATH}\n";
    print " CHILD: PATH is ",`echo \$PATH`,"\n";

The proper output seems pretty obvious, right? And that's what it does
when I run it from the command-line. But under mod_perl 2, instead I
see:

    PARENT: PATH is /usr/bin
     CHILD: PATH is 
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin

I'm using Ubuntu 8.04 and its default Perl (5.8.8), Apache (2.2.8),
and mod_perl (2.0.3). My Apache configuration looks roughly like this:

    <Location /cgi-perl>
        Options +ExecCGI
        PerlSendHeader On
        SetHandler perl-script
        PerlHandler ModPerl::Registry
        PerlOptions +SetupEnv
        allow from all
    </Location>

Any suggestions would be appreciated!

----Scott.

Reply via email to