[Pdx-pm] how to append to library path?

Tom Phoenix rootbeer at redcat.com
Mon Dec 15 20:14:26 CST 2003

On Mon, 15 Dec 2003, Nathaniel Powning wrote:

> What if you're an individual user wanting to include your own modules
> while using the global perl binary?  Is it not okay to populate your own
> @INC or push an additional value into it?

Sure, nothing wrong with that. Or with setting PERL5LIB and forgetting
about it.

The underlying suggestion is to fix up Perl to always do something like
this before it compiles any other code:

    if (-r "/home/barney/.perl-config.pl") {
        require "/home/barney/.perl-config.pl";

That file could then set up the proper @INC paths or do all sorts of other
initialization. The cost would be that this check would slightly slow down
every invocation of Perl when you don't have such a file. (It's pretty
small, but some systems launch a Perl program more than 1000 times per
second. It adds up.)

But how would the system-wide Perl binary know where to find that file?
The path to _something_ has to be compiled into Perl. So, as Randal said,
Larry chose the simpler route of compiling the @INC paths, rather than a
specific filename.

But Larry gives us the tools to do something like what you want, with
PERL5LIB and the -M command-line option. Would one of those be what you're
looking for?

After all, if you can't modify the system-wide perl binary, and you can't
change the environment variables, and you can't alter the invocation
options on the command line, and you can't change the source code to your
programs, it can be hard to get Perl to do what you want.


More information about the Pdx-pm-list mailing list