Re: Mod_perl question

From: Joshua Kugler <joshua.kugler@uaf.edu>
Date: Thu Aug 25 2005 - 15:22:09 AKDT

On Thursday 25 August 2005 14:49, Anthony Valentine wrote:
> I think the INC path is set at compile time (someone correct me if I'm
> wrong), but you can modify it within your script by adding to the @INC
> array like so:
>
> unshift @INC, "/usr/opt/perl5/lib/site_perl";
>
> Of course, substitute your need path.

Yes...but if you simply insert that, it will be executed after perl has=20
already tried to find your module. What you need to do is put it in a Begi=
n=20
block:

BEGIN {
unshift @INC, 'path/to/modules';
}

=46rom the Perlmod POD:

"A BEGIN subroutine is executed as soon as possible, that is, the moment it=
 is=20
completely defined, even before the rest of the containing file is parsed.=
=20
You may have multiple BEGIN blocks within a file--they will execute in orde=
r=20
of definition. Because a BEGIN block executes immediately, it can pull in=20
definitions of subroutines and such from other files in time to be visible =
to=20
the rest of the file. Once a BEGIN has run, it is immediately undefined and=
=20
any code it used is returned to Perl's memory pool. This means you can't ev=
er=20
explicitly call a BEGIN."

j----- k-----

=2D-=20
Joshua Kugler
CDE System Administrator
http://distance.uaf.edu/
---------
To unsubscribe, send email to <aklug-request@aklug.org>
with 'unsubscribe' in the message body.
Received on Thu Aug 25 15:22:13 2005

This archive was generated by hypermail 2.1.8 : Thu Aug 25 2005 - 15:22:13 AKDT