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.
PerlModule Apache::RegistryLoader
<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>
I 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.
Now Playing: Beyond Beautiful - Aerosmith (Just push play)
There's still people using Apache::Registry? (Score:1)
Probably semantic confusion and people didn't understand you meant registry/CGI stuff rather than Apache API modules. At least that's what I thought at first until I read the entire thing. Then again I do most everything with HTML::Mason [masonhq.com].
Well except for the one line inline PerlTransHandler the other day (to work around the fact that the neens that printed business cards for my wife helpfully prefixed a `www' on the URL for her site that she must have obviously forgotten because everyone knows that you