Reference Link: http://stackoverflow.com/questions/841785/how-do-i-include-a-perl-module-thats-in-a-different-directory Http://stackoverflow.com/questions/185114/how-do-i-use-a-perl-module-in-a-directory-not-in-inc
In Fedora/rhel/centos, the library default installation path for Perl is:
@INC (@INC contains:/usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/usr/lib/perl5/site_perl/5.8.8/usr /lib/perl5/site_perl/usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi/usr/lib/perl5/vendor_perl/ 5.8.8/usr/lib/perl5/vendor_perl/usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/usr/lib/perl5/5.8.8.)
If you want to use a custom perllib, you need to refer to the following settings.
Edit:putting the right solution and originally from this question. It ' s The only one, searches relative to the module directory:
Use Findbin; # Locate this script
Use Lib "$FindBin:: bin/..."; # Use the parent directory
Use Yourlib;
There ' s Many other ways this search for libraries relative to the current directory. Can invoke Perl with the-i argument, passing the directory of the other module:
Perl-i.. yourscript.pl
Can include a line near the top of your Perl script:
Use Lib ' ... ';
Can modify the environment variable perl5lib before you run the script:
Export perl5lib= $PERL 5LIB:.
The push (@INC) strategy can also work, but it has to being wrapped in begin{} to make sure the "push is run before" Mo Dule Search:
BEGIN {push @INC, '.. '}
Use Yourlib;