加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

Perl的library设置

发布时间:2020-12-16 00:39:29 所属栏目:大数据 来源:网络整理
导读:参考链接: 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 ? 在Fedora/RHEL/CentOS中,per

参考链接:

  1. http://stackoverflow.com/questions/841785/how-do-i-include-a-perl-module-thats-in-a-different-directory
  2. http://stackoverflow.com/questions/185114/how-do-i-use-a-perl-module-in-a-directory-not-in-inc

?

在Fedora/RHEL/CentOS中,perl 的library默认安装路径为:

?

如果要使用自定义的perllib,就需要参考以下的设置了。

?

EDIT: Putting the right solution first,originally from?this question. It's the only one that 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 that search for libraries relative to the?current?directory. You can invoke perl with the -I argument,passing the directory of the other module:

perl -I.. yourscript.pl

You can include a line near the top of your perl script:

use lib '..';

You can modify the environment variable PERL5LIB before you run the?script:

export PERL5LIB=$PERL5LIB:..

The push(@INC) strategy can also work,but it has to be wrapped in BEGIN{} to make sure that the push is run before the module search:

BEGIN {push @INC, '..'}
use yourlib;

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读