如何在系统级别向Perl库路径添加目录?

时间:2021-04-06 23:20:36

On a standard linux set up, where can I add a directory to the @INC variable?

在标准的linux设置上,我可以在哪里向@INC变量添加目录?

In the /etc/profile file, I added:

在/etc/profile文件中,我添加了:

 export PERLLIB=$PERLLIB:/foo/bar
 export PERL5LIB=$PERL5LIB:/foo/bar

Thanks

谢谢

4 个解决方案

#1


2  

If you want every Perl script to have the additional library paths, you can re-compile Perl and specify the extra directories as part of the setup. Other than that, you're stuck with the ad hoc methods as you describe.

如果希望每个Perl脚本都有附加的库路径,那么可以重新编译Perl并在设置中指定额外的目录。除此之外,你还会被你所描述的特殊方法困住。

#2


2  

You might also need to source your ~/.bashrc so that it rebuilds your environment, or log out and log back in, before this change takes effect. At least this would be required if you made that change in your local ~/.bash_profile instead of system wide.

您可能还需要找到您的~/。bashrc以便它在此更改生效之前重新构建您的环境,或者注销并重新登录。如果您在您的本地~/中做了那样的更改,至少需要这样做。bash_profile代替系统范围。

#3


0  

Question 1: Cannot locate ... in @INC - Perl Maven
Question 2: How to install the module
Question 3: Where I have installed my module

问题1:无法定位…在@INC - Perl Maven问题2:如何安装模块问题3:我在哪里安装了模块

Question 4: how to load module

问题4:如何加载模块

Answer 1:

回答1:

module path is not in the @INC. You need add the path to @INC

Answer 2:

答案2:

cpan
install Sort::Array

Answer 3:

答案3:

perldoc -l XML::Simple
perldoc -l Sort::Array

Answer 4:

回答4:

export PERL5LIB=$PERL5LIB:/home/shg047/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/Sort/
export PERLLIB=$PERLLIB:/home/shg047/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/Sort/
        source ~/.bashrc 

#4


0  

Below command helps to fix this issue. use lib "/usr/print";

下面的命令有助于解决这个问题。使用“/ usr / lib打印”;

#1


2  

If you want every Perl script to have the additional library paths, you can re-compile Perl and specify the extra directories as part of the setup. Other than that, you're stuck with the ad hoc methods as you describe.

如果希望每个Perl脚本都有附加的库路径,那么可以重新编译Perl并在设置中指定额外的目录。除此之外,你还会被你所描述的特殊方法困住。

#2


2  

You might also need to source your ~/.bashrc so that it rebuilds your environment, or log out and log back in, before this change takes effect. At least this would be required if you made that change in your local ~/.bash_profile instead of system wide.

您可能还需要找到您的~/。bashrc以便它在此更改生效之前重新构建您的环境,或者注销并重新登录。如果您在您的本地~/中做了那样的更改,至少需要这样做。bash_profile代替系统范围。

#3


0  

Question 1: Cannot locate ... in @INC - Perl Maven
Question 2: How to install the module
Question 3: Where I have installed my module

问题1:无法定位…在@INC - Perl Maven问题2:如何安装模块问题3:我在哪里安装了模块

Question 4: how to load module

问题4:如何加载模块

Answer 1:

回答1:

module path is not in the @INC. You need add the path to @INC

Answer 2:

答案2:

cpan
install Sort::Array

Answer 3:

答案3:

perldoc -l XML::Simple
perldoc -l Sort::Array

Answer 4:

回答4:

export PERL5LIB=$PERL5LIB:/home/shg047/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/Sort/
export PERLLIB=$PERLLIB:/home/shg047/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/Sort/
        source ~/.bashrc 

#4


0  

Below command helps to fix this issue. use lib "/usr/print";

下面的命令有助于解决这个问题。使用“/ usr / lib打印”;