美文网首页
perl系列-1:模块

perl系列-1:模块

作者: 扇子和杯子 | 来源:发表于2020-05-18 15:30 被阅读0次

1.模块安装

1.1默认安装位置

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

  • perl:存储Perl本身包含的模块
  • vendor:可能存储一些二进制perl文件安装的模块
  • site:存储cpan安装的模块

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

perl -V:'install.*'
1.2改变安装位置
  • 自己下源码安装,把安装位置添加到INC里
#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
  • cpan默认安装,然后通过cp命令把要的文件转移到指定目录里
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

相关文章

网友评论

      本文标题:perl系列-1:模块

      本文链接:https://www.haomeiwen.com/subject/hbguohtx.html