Preloading mod_perl Scripts
I was trying to figure out how to preload mod_perl scripts, and I was told by several people to use the PerlRequire directive. The problem is, that's entirely wrong.
PerlRequire just does a require(). But what mod_perl does, via Apache::Registry, is load the text of the script, add some stuff to it, including a new package directive, eval it, and install it into its registry. A require(), or PerlRequire, will not do anything to help here.
The correct answer is Apache::RegistryLoader. I ended up using something like this.
PerlRequire just does a require(). But what mod_perl does, via Apache::Registry, is load the text of the script, add some stuff to it, including a new package directive, eval it, and install it into its registry. A require(), or PerlRequire, will not do anything to help here.
The correct answer is Apache::RegistryLoader. I ended up using something like this.
PerlModule Apache::RegistryLoaderI know this is in various FAQs, but 1. my DNS was acting up and I was having trouble getting anywhere, 2. I found plenty of people contradicting the FAQs, and 3. I had to add the virtual host parameter before it would work properly (else it would install the script in a different package than what it would be called as later), which wasn't in the FAQ.
<Perl>
my @pls = qw(names of scripts or something);
my $vhost = 'hostname.example.com';
my $docroot = '/path/to/scripts';
my $r = Apache::RegistryLoader->new;
for my $u (@pls) {
my $f = "$docroot/$u.pl";
$r->handler("/$u.pl", $f, $vhost) if -e $f;
}
</Perl>
Now Playing: Beyond Beautiful - Aerosmith (Just push play)
Leave a comment