Library Settings for Perl

Source: Internet
Author: User
Tags parent directory perl script

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;

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.