Print service provided by iDogiCat: http://www.idogicat.com/
home logo





Home > IT > Programming > PERL > How to use Perl libs at non-standard places

How to use Perl libs at non-standard places

iDog

Sometimes we need to or have to install Perl libs to a place that is not the standard place, for example, developers need to install some Perl modules in their home dirs before SA can do it formally. In this case, we can access them in one of following ways:

1. use lib


#!/ usr / bin / perl

use lib "/path/to/mylibs";

2. command line inclusion


perl -I /path/to/mylibs my_script.pl

3. inclusion in shebang line


#!/ usr / bin / perl -I /path/to/mylibs

4. @INC

Perl searches path in @INC for modules to load.


#!/ usr / bin / perl

BEGIN {
    unshift(@INC, "/path/to/mylibs");
    unshift(@INC, "/path/to/mylibs1");
}

use strict;

#...

5. env


PERL5LIB=/path/to/mylibs:$PERL5LIB
export PERL5LIB