Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Changing @INC path detail

by dynamo (Chaplain)
on Dec 05, 2007 at 20:54 UTC ( [id://655221]=note: print w/replies, xml ) Need Help??


in reply to Changing @INC path detail

use lib is the Right way to do it, but you can also do it the same way you manipulate any other array:
my $override_lib_path = "/usr/local/Perl/5.8.6/whatever"; my $backup_lib_path = "/lastresort/path/to/lib"; # look in $override_lib_path first unshift @INC, $override_lib_path; # look in $backup_lib_path last if # no match for a module name is found first push @INC, $backup_lib_path;
Good luck.

Replies are listed 'Best First'.
Re^2: Changing @INC path detail
by moritz (Cardinal) on Dec 05, 2007 at 21:00 UTC
    You have to take care that you fold that into a BEGIN block, because use is evaluated at compile time.

    If you have a script like this:

    # modify @INC use Some::Module;
    the use is evaluated before the # modify @ING line.

    You see, it's not as easy at it looks, which is why use lib $path; is recommended. (It checks for duplicate entries in @INC as well, which is another advantage).

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://655221]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (3)
As of 2024-04-19 19:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found