perl下安装模块可以使用cpan命令,但是通常我们不具有root用户权限,所以只能以sudo方式安装模块。
例如需要安装Net::SCP::Expect模块,
执行cpan Net::SCP::Expect
首次使用cpan命令会出现 choice local or sudo的样式,默认为local,建议使用sudo.
最后会出现
ERROR: Can't create '/usr/local/man/man3' Do not have write permissions on '/usr/local/man/man3' !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! at -e line 1. Makefile:706: recipe for target 'pure_site_install' failed make: *** [pure_site_install] Error 13 RYBSKEJ/Net-SCP-Expect-0.16.tar.gz /usr/bin/make install -- NOT OK ---- You may have to su to root to install the package (Or you may want to run something like o conf make_install_make_command 'sudo make'
由于非root用户无法在/usr/local目录下进行操作。
执行sudo cpan Net::SCP::Expect
即可正常安装模块。
未安装cpan
[root@idip bin]# cpan Recursive bash: cpan: 未找到命令... [root@idip bin]# ppm install File::Copy::Recursive bash: ppm: 未找到命令... [root@idip bin]# sudo perl -MCPAN -e shell Can't locate CPAN.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .). BEGIN failed--compilation aborted. [root@idip bin]# yum -y install perl-CPAN 已加载插件:fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com
参考:查看安装的perl模块版本的方法
手动查询的方法
查询path: perldoc -l $1
查询版本: perl -M$1 -e 'print $1->VERSION. "\n"'
一个例子:
[root@atlas73 ~]# perl -MConfig::IniFiles -e 'print Config::IniFiles->VERSION. "\n"'
没安装此模块,则输出如下
Can't locate Config/IniFiles.pm in @INC (you may need to install the Config::IniFiles module) (@INC contains: /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.22.2 /usr/local/share/perl/5.22.2 /usr/lib/x86_64-linux-gnu/perl5/5.22 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.22 /usr/share/perl/5.22 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base .). BEGIN failed--compilation aborted.
另一个例子
[root@atlas73 ~]$ perl -MNet::SCP::Expect -e 'print Net::SCP::Expect->VERSION. "\n"'
已安装此模块,输出版本号:
0.16
2.66
删除已安装的模块:
使用App::pmunintsall模块来实现:cpan>install App::pmuninstall
安装完成后,退出cpan
执行删除模块操作:cmd>pm-uninstall DBD::Oracle