cpanm是安装Perl模块的最方便的方法。自动下载安装依赖包。使用CPAN shell或下载源码包安装模块,遇到大量依赖关系,非常头痛。下面就是一例:
安装MongoDB模块
代码如下:
# perl Makefile.PL
Warning: prerequisite Class::Method::Modifiers 0 not found.
Warning: prerequisite Data::Types 0 not found.
Warning: prerequisite DateTime 0 not found.
Warning: prerequisite DateTime::Tiny 0 not found.
Warning: prerequisite ExtUtils::MakeMaker 6.59 not found. We have 6.30.
Warning: prerequisite File::Slurp 0 not found.
Warning: prerequisite File::Temp 0.17 not found. We have 0.16.
Warning: prerequisite JSON 0 not found.
Warning: prerequisite Moose 0 not found.
Warning: prerequisite Test::Exception 0 not found.
Warning: prerequisite Test::Warn 0 not found.
Warning: prerequisite Tie::IxHash 0 not found.
Warning: prerequisite Try::Tiny 0 not found.
Warning: prerequisite boolean 0 not found.
Writing Makefile for MongoDB
1. 安装cpanm
cpanm其实是一个可执行文件而已。将它下载到bin目录,然后添加执行权限就可以了。
代码如下:
# wget http:
//xrl.us/cpanm -O /usr/bin/cpanm; chmod +x /usr/bin/cpanm
2. 使用cpanm安装模块
代码如下:
# cpanm -h
-v,--verbose Turns on chatty output
-q,--quiet Turns off the most output
--interactive 开启交互配置(required for Task:: modules)
-f,--force 强制安装
-n,--notest Do not run unit tests
--test-only 只测试不安装
-S,--sudo sudo to run install commands
--installdeps 只安装依赖模块
--showdeps 只显示依赖信息
--reinstall 重新安装
--mirror 指定镜像url (e.g. http://cpan.cpantesters.org/)
--mirror-only 只从镜像下载
--prompt Prompt when configure/build/test fails
新闻热点
疑难解答