Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

pudge (1)

  (email not shown publicly)
AOL IM: Crimethnk (Add Buddy, Send Message)

I run this joint, see?

Journal of pudge (1)

Thursday January 16, 2003
09:47 AM

Preloading mod_perl Scripts

[ #10013 ]

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
my @pls     = qw(names of scripts or something);
my $vhost   = '';
my $docroot = '/path/to/scripts';
my $r       = Apache::RegistryLoader->new;
for my $u (@pls) {
    my $f = "$docroot/$";
    $r->handler("/$", $f, $vhost) if -e $f;

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)

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • 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 [].

    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