How can my Perl program tell if is running under mod_perl?
Question
How can my Perl program tell if is running under mod_perl?
I'm thinking along the lines of global variables or environment variables.
I am only bothered about mod_perl >= 2.
Solution 2
http://perl.apache.org/docs/2.0/user/coding/coding.html#Environment_Variables says that there will be an environment variable MOD_PERL
, so you could test for that using the expression
exists $ENV{MOD_PERL}
OTHER TIPS
According to "Environment Variables" in the mod_perl user's guide:
$ENV{MOD_PERL}
- is set to the mod_perl version the server is running under. e.g.:mod_perl/2.000002If
$ENV{MOD_PERL}
doesn't exist, most likely you are not running under mod_perl.die "I refuse to work without mod_perl!" unless exists $ENV{MOD_PERL};
(see the above link for more information).
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow