Is it possible in to detect in web app run under mod_perl if it is run using ModPerl::Registry?
I want to write script which would run under ModPerl::Registry (or similar handler), but can function also as mod_perl response handler.
Is it possible in to detect in web app run under mod_perl if it is run using ModPerl::Registry?
I want to write script which would run under ModPerl::Registry (or similar handler), but can function also as mod_perl response handler.
ModPerl::Registry does an elaborate dance to isolate your code from everything else in the system, and part of that is compiling it into a package beneath ModPerl::ROOT
.
When called in list context with an argument specifying the number of frames to go back, caller
returns
# 0 1 2 3 4 ($package, $filename, $line, $subroutine, $hasargs, # 5 6 7 8 9 10 $wantarray, $evaltext, $is_require, $hints, $bitmask, $hinthash) = caller($i);
where the $subroutine
value is a fully-qualified name.
ModPerl::Registry wraps your entire program in a sub named handler
in the aforementioned artificial package, so from your main program, use a test similar to
my $name = (caller 0)[3];
if ($name =~ /^ModPerl::ROOT::/) {
# run using ModPerl::Registry
...
}