Monday, April 6, 2015

Perl - extend lib path

See: http://www.perlhowto.com/extending_the_library_path

This is useful when you want to use personal lib for perl modules, which is not on perl path (@INC) and cannot be found.

3 methods are mentioned.

1) The non-invasive method is to use -I switch:

perl -I /home/path/lib -I /usr/another/lib script.pl

2) add path to environment:

# unix, bourne shell
PERL5LIB=/home/path/lib:/usr/another/path/lib; export PERL5LIB


3) add path to perl code:

#!/usr/bin/perl
use lib "/home/path/lib";
use lib "/usr/another/lib";

use MyCustomModule;

No comments:

Blog Archive

Followers