perl系列-1:模块

2020-05-18  本文已影响0人  扇子和杯子

1.模块安装

1.1默认安装位置

perl根据来源指定三个目录:perl、vendor、site。


可以通过下面这个命令,查看当前各个文件的默认存储位置

perl -V:'install.*'
1.2改变安装位置
#https://metacpan.org
wget http://www.cpan.org/authors/id/G/GA/GAAS/URI-1.60.tar.gz

tar -zxvf URI-1.60.tar.gz

cd URI-1.60

perl Makefile.PL

make

make install
cp -r Class /picb/evolgen/users/gushanshan/GenomeAnnotation/perlModule/lib/perl5

参考https://www.jianshu.com/p/a8c61bbedd3c

2.查看模块相关信息

2.1查看模块是否安装成功
perl -MModuleName -e "print\"module installed\n\""
2.2查看模块的安装路径
perldoc -l ModuleName

3. INC

perl的INC是其所有模块的查找路径

3.1. 查看INC
perl -e 'print join("\n",@INC)'
3.2.添加INC

在~/.bashrc文件中,加入

export PERL5LIB=“newpath:$PERL5LIB”

附录:
1. cpan:
cpan 下载CPAN的模块源码,然后运行源码里的安装程序,比如Makefile.PL and Build.PL。cpan并不会安装文件

2.PERL5LIB:
PERL5LIB不影响安装过程,只在加载过程中发挥作用。比如你把源码安装到dir,为了运行时能找到,要通过export PERL5LIB="dir:PERL5LIB$"把dir添加到INC里
3.参考
https://stackoverflow.com/questions/46778215/where-does-cpan-install-modules
https://stackoverflow.com/questions/2434340/how-can-i-tell-cpan-to-change-the-target-for-the-module-installation
https://stackoverflow.com/questions/540640/how-can-i-install-a-cpan-module-into-a-local-directory
https://stackoverflow.com/questions/51880115/install-with-cpan-perl-modules-to-specific-directory-when-several-appear-in-us
https://www.perlmonks.org/?node_id=630026

上一篇 下一篇

猜你喜欢

热点阅读