cpanm安装及Perl模块安装教程
cpanm是安装Perl模块的最方便的方法。自动下载安装依赖包。使用CPANshell或下载源码包安装模块,遇到大量依赖关系,非常头痛。下面就是一例:
安装MongoDB模块
#perlMakefile.PL Warning:prerequisiteClass::Method::Modifiers0notfound. Warning:prerequisiteData::Types0notfound. Warning:prerequisiteDateTime0notfound. Warning:prerequisiteDateTime::Tiny0notfound. Warning:prerequisiteExtUtils::MakeMaker6.59notfound.Wehave6.30. Warning:prerequisiteFile::Slurp0notfound. Warning:prerequisiteFile::Temp0.17notfound.Wehave0.16. Warning:prerequisiteJSON0notfound. Warning:prerequisiteMoose0notfound. Warning:prerequisiteTest::Exception0notfound. Warning:prerequisiteTest::Warn0notfound. Warning:prerequisiteTie::IxHash0notfound. Warning:prerequisiteTry::Tiny0notfound. Warning:prerequisiteboolean0notfound. WritingMakefileforMongoDB
1.安装cpanm
cpanm其实是一个可执行文件而已。将它下载到bin目录,然后添加执行权限就可以了。
#wgethttp: //xrl.us/cpanm-O/usr/bin/cpanm;chmod+x/usr/bin/cpanm
2.使用cpanm安装模块
#cpanm-h -v,--verbose Turnsonchattyoutput -q,--quiet Turnsoffthemostoutput --interactive 开启交互配置(requiredforTask::modules) -f,--force 强制安装 -n,--notest Donotrununittests --test-only 只测试不安装 -S,--sudo sudotoruninstallcommands --installdeps 只安装依赖模块 --showdeps 只显示依赖信息 --reinstall 重新安装 --mirror 指定镜像url(e.g.http://cpan.cpantesters.org/) --mirror-only 只从镜像下载 --prompt Promptwhenconfigure/build/testfails -l,--local-lib Specifytheinstallbasetoinstallmodules -L,--local-lib-contained Specifytheinstallbasetoinstallallnon-coremodules --self-contained Installallnon-coremodules,evenifthey'realreadyinstalled. --auto-cleanup Numberofdaysthatcpanm'sworkdirectoriesexpirein.Defaultsto7
Examples: cpanmTest::More #installTest::More cpanmMIYAGAWA/Plack-0.99_05.tar.gz #fulldistributionpath cpanmhttp://example.org/LDS/CGI.pm-3.20.tar.gz #installfromURL cpanm~/dists/MyCompany-Enterprise-1.00.tar.gz #installfromalocalfile cpanm--interactiveTask::Kensho #Configureinteractively cpanm. #installfromlocaldirectory cpanm--installdeps. #installallthedepsforthecurrentdirectory cpanm-LextlibPlack #installPlackandallnon-coredepsintoextlib cpanm--mirrorhttp://cpan.cpantesters.org/DBI #usethefast-syncingmirror