perl学习笔记
2021-08-04 本文已影响0人
胡童远
查询,安装模块
perl -e 'use Data::Dumper' # 不报错说明模块已经存在
perldoc -l Data::Dumper # 查看某一个模块的安装路径
perldoc perllocal | grep 'Module'
# 查看已有模块,不全
# /home/cheng/perl5/lib/perl5
instmodsh
# 查看已有模块,全
# 在模块文件夹中查看最全
perl -V # 查看每个conda中perl @INC等环境配置
cpan install module # 安装
cpanm module # 安装
perl -MCPAN -e 'install module' # 安装
perl -MCPAN -e shell
install module # 安装
sudo instmodsh # sudo查看,最全
sudo find -name 'module.pl' # 查找需要的module.pm文件位置,export lib的路径
# sudo全部已经安装
# 因为这些模块在不同的路径中,添加所有需要的路径到@INC
# export PERL5LIB="path1:path2:path3" # 添加路径搭配perl @INC数组
export PERL5LIB="/home/cheng/miniconda2/envs/metawrap-env/lib/site_perl/5.26.2/x86_64-linux-thread-multi:/home/cheng/miniconda2/envs/metawrap-env/lib/site_perl/5.26.2"
# 把所有需要的模块的路径添加到perl @INC数组
安装Date::Calc
perl CRISPRCasFinder.pl -h
# Can't locate Date/Calc.pm
perl -MCPAN -e 'install Date::Calc'
perl -e 'use Date::Calc'
find -name 'Calc.pm'
# ./.cpan/build/Date-Calc-6.4-0/blib/lib/Date/Calc.pm
# ./.cpan/build/Date-Calc-6.4-0/lib/Date/Calc.pm
# 把Date/Calc.pm的路径export到perl环境
export PERL5LIB="/home/cheng/.cpan/build/Unix-Sysexits-0.06-0/blib/lib:/home/cheng/.cpan/build/Unix-Sysexits-0.06-0/lib:/home/cheng/.cpanm/work/1592559386.15556/Unix-Sysexits-0.06/blib/lib:/home/cheng/.cpanm/work/1592559386.15556/Unix-Sysexits-0.06/lib"
安装Unix::Sysexits
perl CRISPRCasFinder.pl -h
# Can't locate Unix/Sysexits.pm
perl -MCPAN -e 'install Unix::Sysexits'
find -name 'Sysexits.pm'
# add path to perl5lib and export
perl -e 'use Unix::Sysexits'
# Can't locate loadable object for module Unix::Sysexits
sudo perldoc perllocal
# /usr/local/share/perl/5.22.1
export PERL5LIB="/home/cheng/.cpan/build/Unix-Sysexits-0.06-0/blib/lib:/home/cheng/.cpan/build/Unix-Sysexits-0.06-0/lib:/home/cheng/.cpanm/work/1592559386.15556/Unix-Sysexits-0.06/blib/lib:/home/cheng/.cpanm/work/1592559386.15556/Unix-Sysexits-0.06/lib:/usr/local/share/perl/5.22.1"
perl -e 'use Unix::Sysexits'
# Can't locate loadable object for module Unix::Sysexits
sudo perl -e 'use Unix::Sysexits'
FindBin
perl 中的 pwd
use FindBin qw($Bin);
my $route_2 = "$Bin/script/code.pl";