Search code examples
perlmod-perl2

How can my Perl program tell if is running under mod_perl?


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

  • 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}