Gary: I don't use the code "local %ENV", if that's what you're asking, but I DO fetch variables from %ENV to determine what kind of environment I'm in. I do not use the Sys::HostIP package.
I'm using the code below (I've cut out the lines that mentions ENV):
<code>
$pf->var('docroot',$ENV{'DOCUMENT_ROOT'} . $uri->path);
my $ip_addr=inet_ntoa(inet_aton($q->remote_host)) || $ENV{'REMOTE_ADDR'};
my $ip_addr=inet_ntoa(inet_aton($q->remote_host)) || $ENV{'REMOTE_ADDR'};
</code>
I also use the following snippet of code to identify if I'm running CGI or mod_perl mode:
<code>
if ($ENV{'MOD_PERL'}) {
eval "use Apache2::ServerUtil ();";
if ($@) {
die __"Apache2/ServerUtil.pm unavilable. Please verify your mod_perl 2.x setup.";
}
if (Apache2::ServerUtil->server->dir_config('PORTFOLIO_HOME')) { $homedir=Apache2::ServerUtil->server->dir_config('PORTFOLIO_HOME'); $bindir=$homedir . '/bin';
} else {
die __"Please set PORTFOLIO_HOME when using mod_perl.";
} $hosting_environment=$ENV{'GATEWAY_INTERFACE'} . "; " . $ENV{'MOD_PERL'};
} elsif ( $ENV{'GATEWAY_INTERFACE'}=~/^CGI\/.*$/ and $ENV{'SCRIPT_FILENAME'}) {
(my $dummy,$bindir,my $dummy2)=File::Spec->splitpath($ENV{'SCRIPT_FILENAME'}); # Split filename from directory
if ( -d $bindir) { $bindir=~s/^(.*)$/$1/; $homedir=$bindir . '/../';
} $hosting_environment=$ENV{'GATEWAY_INTERFACE'};
} else { $bindir=$FindBin::Bin;
# Untaint directory if it's valid
if ( -d $bindir) { $bindir=~s/^(.*)$/$1/; $homedir=$bindir . '/../';
} $hosting_environment='CLI';
}
</code>
I'm also using this code in /etc/apache2/mods-enabled/perl.conf:
<code>
# Make sure files with .pl extension are run as mod_perl scripts
AddHandler perl-script .pl
# Make sure these point to the base folder of the application
Gary: I don't use the code "local %ENV", if that's what you're asking, but I DO fetch variables from %ENV to determine what kind of environment I'm in. I do not use the Sys::HostIP package.
I'm using the code below (I've cut out the lines that mentions ENV):
<code> 'docroot' ,$ENV{' DOCUMENT_ ROOT'} . $uri->path); inet_ntoa( inet_aton( $q->remote_ host)) || $ENV{'REMOTE_ ADDR'}; inet_ntoa( inet_aton( $q->remote_ host)) || $ENV{'REMOTE_ ADDR'};
$pf->var(
my $ip_addr=
my $ip_addr=
</code>
I also use the following snippet of code to identify if I'm running CGI or mod_perl mode:
<code>
if ($ENV{'MOD_PERL'}) {
eval "use Apache2::ServerUtil ();";
if ($@) { ServerUtil. pm unavilable. Please verify your mod_perl 2.x setup.";
die __"Apache2/
}
if (Apache2: :ServerUtil- >server- >dir_config( 'PORTFOLIO_ HOME')) {
$homedir= Apache2: :ServerUtil- >server- >dir_config( 'PORTFOLIO_ HOME');
$bindir= $homedir . '/bin';
$hosting_ environment= $ENV{'GATEWAY_ INTERFACE' } . "; " . $ENV{'MOD_PERL'}; INTERFACE' }=~/^CGI\ /.*$/ and $ENV{'SCRIPT_ FILENAME' }) { =File:: Spec->splitpath ($ENV{' SCRIPT_ FILENAME' }); # Split filename from directory
$bindir= ~s/^(.* )$/$1/;
$homedir= $bindir . '/../';
$hosting_ environment= $ENV{'GATEWAY_ INTERFACE' };
$bindir= $FindBin: :Bin;
$bindir= ~s/^(.* )$/$1/;
$homedir= $bindir . '/../';
$hosting_ environment= 'CLI';
} else {
die __"Please set PORTFOLIO_HOME when using mod_perl.";
}
} elsif ( $ENV{'GATEWAY_
(my $dummy,$bindir,my $dummy2)
if ( -d $bindir) {
}
} else {
# Untaint directory if it's valid
if ( -d $bindir) {
}
}
</code>
I'm also using this code in /etc/apache2/ mods-enabled/ perl.conf:
<code>
# Make sure files with .pl extension are run as mod_perl scripts
AddHandler perl-script .pl
# Make sure these point to the base folder of the application
PerlSetVar PORTFOLIO_HOME "/home/ portfolio/ portfolio" portfolio/ portfolio/ lib
PerlSwitches -w -I/home/
# Portfolio is a full ModPerl::Registry script.
PerlOptions +ParseHeaders
PerlOptions +SetupEnv
PerlResponseHandler ModPerl::Registry
# Automatic reload check of changed modules at each request.
# Useful in development, but shouldn't be used in production.
PerlInitHandler Apache2::Reload
</code>