How do I add a directory to my include path (@INC) at runtime?

来源:互联网 发布:linux rm rf 恢复 编辑:程序博客网 时间:2024/05/11 12:34
How do I add a directory to my include path (@INC) at runtime?

Here are the suggested ways of modifying your include path, including environment variables, run-time switches, and in-code statements:

  • the PERLLIB environment variable
    $ export PERLLIB=/path/to/my/dir$ perl program.pl
  • the PERL5LIB environment variable
    $ export PERL5LIB=/path/to/my/dir$ perl program.pl
  • the perl -Idir command line flag
    $ perl -I/path/to/my/dir program.pl
  • the use lib pragma:
    use lib "$ENV{HOME}/myown_perllib";

The last is particularly useful because it knows about machine dependent architectures. The lib.pm pragmatic module was first included with the 5.002 release of Perl.

原创粉丝点击