You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by ro...@elastica.com on 2006/08/01 22:38:02 UTC
Confused about variable scope.
So if my httpd.conf has multiple <Perl> sections and I am doing something like
this in the first one.
for (`env`) {
next unless /^X_/;
/(.*)=(.*)/;
$ENV{$1} = $2;
push @PassEnv, $1;
#print "$_\n";
}
and I then do
my $somevariable = $ENV{'X_KEY'};
in other Perl sections are these variables defined and what
are their values.
and is %ENV also populated in those Perl sections?
Do I have to repeat the above code in every Perl Section where I want
access to these values?
----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.
Re: Confused about variable scope.
Posted by ro...@elastica.com.
The approach I'm using is the suggested approach in the mod perl book.
Basically setup the environment in order to pass information to apache so that
it's available in httpd.conf and then in httpd.conf to use mod perl to
interrogate %ENV. One problem is that mod_perl clears out %ENV so what you see
below is a way to repopulate it after that has happened.
Quoting Jonathan Vanasco <jo...@2xlp.com>:
>
> On Aug 1, 2006, at 4:38 PM, robert@elastica.com wrote:
> > for (`env`) {
> > next unless /^X_/;
> > /(.*)=(.*)/;
> > $ENV{$1} = $2;
> > push @PassEnv, $1;
> > #print "$_\n";
> > }
> >
> > and I then do
> >
> > my $somevariable = $ENV{'X_KEY'};
>
> my question is what exactly are you trying to do? this sounds like a
> really assbackwards way to do what you really want done.
>
----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.
Re: Confused about variable scope.
Posted by Jonathan Vanasco <jo...@2xlp.com>.
On Aug 1, 2006, at 4:38 PM, robert@elastica.com wrote:
> for (`env`) {
> next unless /^X_/;
> /(.*)=(.*)/;
> $ENV{$1} = $2;
> push @PassEnv, $1;
> #print "$_\n";
> }
>
> and I then do
>
> my $somevariable = $ENV{'X_KEY'};
my question is what exactly are you trying to do? this sounds like a
really assbackwards way to do what you really want done.