Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

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).