You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Jeff Nokes <je...@yahoo.com> on 2003/07/03 00:36:10 UTC

Wierd ENV issues

Greetings,
I have a W2K box, running Win32 binary of Apache 1.3.27, and mod_perl 1.27_01.
 Everything seems to be working fine (AFAIK) except for some strange
environment variable stuff going on.  Here is what I'm experiencing:

- I have a "PerlRequire C:/startup.pl" line in my httpd.conf, which works
fine.  I set some ENVs in there, one of them being $ENV{HTML_TEMPLATE_ROOT} to
use with the HTML::Template module.

- I have a standard CGI test page that does the following:
# Print out the contents of %ENV just for kicks
my @keys = keys(%ENV);
@keys = sort(@keys);
foreach my $temp (@keys) {
print($temp . "  =>  " . $ENV{$temp} . "\n<BR>");
} # end foreach loop

This CGI page prints out all of my ENVs in order, just like one would think,
and it includes the 'HTML_TEMPLATE_ROOT' as it should.

- I also have an equivalent mod_perl based page utilizing Apache::Registry
vice vanilla CGI.  It contains the following:
# Get the Apache::Request object reference
my  $r = shift;
# Print out $ENV{HTML_TEMPLATE_ROOT}
$r -> print("HTML_TEMPLATE_ROOT = " . $ENV{HTML_TEMPLATE_ROOT} . "\n<BR>");
# Print out the entire %ENV hash
my @keys = keys(%ENV);
@keys = sort(@keys);
foreach my $temp (@keys) {
$r -> print($temp . "  =>  " . $ENV{$temp} . "\n<BR>");
} # end foreach loop

This mod_perl based script also prints out everything fine, until I comment
out the line the only prints out the 'HTML_TEMPLATE_ROOT' ENV.  When I comment
it out, all of the sudden, the %ENV hash dump doesn't have it anymore either. 
And when I uncomment it, the %ENV hash dump magically has it again.  I've even
included a count for the %ENV display dump and it even says 31 when I am
printing HTML_TEMPLATE_ROOT, and 30 when I'm not.

I still have that ENV defined in my startup.pl.  I've made sure my browser is
not caching pages, and I've restarted Apache a zillion times, still the same
behavior.  One thing to note is that even when I comment out that single print
line for the ENV in the mod_perl based script, the CGI based one still
displays 'HTML_TEMPLATE_ROOT' properly, irregardless of whether the mod_perl
one does or not.  I really stumbled onto this from blind luck, but it seems to
me that something kind of screwy is happening inside mod_perl or Apache.  Can
someone shed some light on this?

Thanks in advance,
 - Jeff