发布于2026-06-29 阅读(0)
扫一扫,手机访问
cpanm 是 Perl 模块安装领域最趁手的工具,没有之一。它最大的好处就是自动处理依赖关系,把那些令人头疼的层层嵌套的依赖包一股脑儿搞定。不过,用传统 CPAN shell 或者手动下载源码包安装模块时,遇到大量依赖的滋味,相信不少人都尝过——那叫一个酸爽。下面这个场景,就很典型。

安装 MongoDB 模块
看到这一长串缺失的依赖警告,是不是头都大了?别急,cpanm 就是来解决这个问题的。
cpanm 本质上就是一个可执行文件,下载到 bin 目录,加上执行权限,就齐活了。
cpanm 提供了丰富的参数选项,掌握几个常用的就能应付大部分场景:
Examples:
cpanm Test::More # install Test::More
cpanm MIYAGAWA/Plack-0.99_05.tar.gz # full distribution path
cpanm http://example.org/LDS/CGI.pm-3.20.tar.gz # install from URL
cpanm ~/dists/MyCompany-Enterprise-1.00.tar.gz # install from a local file
cpanm --interactive Task::Kensho # Configure interactively
cpanm . # install from local directory
cpanm --installdeps . # install all the deps for the current directory
cpanm -L extlib Plack # install Plack and all non-core deps into extlib
cpanm --mirror http://cpan.cpantesters.org/ DBI # use the fast-syncing mirror
参数名直接为模块名称。比如安装 MongoDB 模块,只需一行命令:
为了加快下载速度,可以指定镜像并强制只从镜像下载:
安装 App::pmuninstall 模块:
售后无忧
立即购买>office旗舰店
售后无忧
立即购买>office旗舰店
售后无忧
立即购买>office旗舰店
售后无忧
立即购买>office旗舰店
正版软件
正版软件
正版软件
正版软件
正版软件
1
2
3
7
8