cpanm是安装Perl模块的最方便的方法。自动下载安装依赖包。使用CPAN shell或下载源码包安装模块,遇到大量依赖关系,非常头痛。下面就是一例:

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
-l,--local-lib Specify the install base to install modules
-L,--local-lib-contained Specify the install base to install all non-core modules
--self-contained Install all non-core modules, even if they're already installed.
--auto-cleanup Number of days that cpanm's work directories expire in. Defaults to 7 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模块

# cpanm MongoDB
--> Working on MongoDB
Fetching http://www.cpan.org/authors/id/F/FR/FRIEDO/MongoDB-0.702.0.tar.gz ... OK
Configuring MongoDB-0.702.0 ... OK
==> Found dependencies: DateTime, Tie::IxHash, Data::Types, DateTime::Tiny, Class::Method::Modifiers, boolean, Moose, File::Slurp, Try::Tiny, Test::Exception, ExtUtils::MakeMaker, Test::Warn, File::Temp, JSON
--> Working on DateTime
...... //自动解决依赖模块

为了加快下载速度, 可以指定使用镜像,并只从镜像下载:

# cpanm --mirror http://mirrors.163.com/cpan --mirror-only MongoDB

3. 删除模块
安装App::pmuninstall模块:

# cpanm App::pmuninstall

删除模块:

# pm-uninstall MongoDB

参考网站:

https://metacpan.org/

使用cpanm安装perl相关模块的更多相关文章

  1. Perl 基础笔记: 使用 cpanm 安装 Perl 模块

    cpanm 其实只是一个可执行文件而已.将它下载到 bin 目录,然后添加执行权限就可以用了. $ sudo wget http://xrl.us/cpanm -O /usr/bin/cpanm; s ...

  2. windows 下安装perl Tk 模块

    首先,安装activeperl ,安装过程中勾选自动添加PATH环境变量,这样安装后就不需要自己手动修改PATH环境变量: 通过cmd 调出命令行窗口,输入ppm ,然后回车,就开启了perl 的包管 ...

  3. ubuntu下安装perl GD模块

    依次执行: sudo apt-get install libgd2-xpm-dev sudo perl -MCPAN -e shell install Bundle::CPAN install GD: ...

  4. linux安装perl模块

    查询perl CPAN模块   shell>perl -MCPAN -e shell cpan>install module_name   手动安装perl CPAN模块 从 CPAN(h ...

  5. CentOS 安装Perl环境

    参考博文:https://blog.csdn.net/weixin_40192129/article/details/78610974 vmware tools需要perl环境的支持 安装perl支持 ...

  6. CentOS 7安装Perl环境

    平台信息 Description: CentOS Linux release 7.6.1810 (Core) 安装步骤 安装支持 $ yum install perl* #安装perl相关支持 $ y ...

  7. centos7 cpanm安装,及perl模块安装

    1. cpan安装 yum安装 yum install perl-App-cpanminus.noarch 注意:安装完成后,root及非root用户都可以使用cpanm安装模块,root用户直接用c ...

  8. 搭建MHA时 yum 安装perl模块提示 baseurl 错误

    今天在搭建MySQL MHA  安装MHA node所需的perl模块(DBD:mysql)时遇到了一个小的错误,如果思路不对的话,还是产生不少麻烦. 现梳理记录下来. 问题现象 执行的命令 yum ...

  9. perl 简单学习,安装perl模块

    检查是否安装了某个perl模块 有多种方式 0.perldoc perlinstall 列出所有的模块及版本号 1. perl -M模块名 -e 1(模块名不加空格) 没有返回值则说明有此模块 2.p ...

随机推荐

  1. springboot整合fastJson遇到重定向问题

    通过网上教程使用springboot整合fastJson后遇到页面重定向问题(使用的springboot版本是2.0.2.RELEASE ,其他的版本可能不会出现以下问题),如下图: 我的项目结构如下 ...

  2. [问题解决]基于注解配置dubbo遇到ConnectionLoss for /dubbo/xxx问题解决

    今天升级spring版本的时候,同时升级dubbo的版本,采用的是dubbo的基于注解的配置方法,采用curator作为dubbo的客户端, curator版本为4.1.0,启动之后,发现一直报错 C ...

  3. PAT 甲级 1044 Shopping in Mars

    https://pintia.cn/problem-sets/994805342720868352/problems/994805439202443264 Shopping in Mars is qu ...

  4. MYSQL InnoDB Cluster

    https://dev.mysql.com/doc/refman/5.7/en/group-replication.html GroupReplication的原理 https://dev.mysql ...

  5. jQuery empty() vs remove()

    https://stackoverflow.com/questions/3090662/jquery-empty-vs-remove http://www.cnblogs.com/yeer/archi ...

  6. FTP Download File By Some Order List

    @Echo Off REM -- Define File Filter, i.e. files with extension .RBSet FindStrArgs=/E /C:".asp&q ...

  7. Linux查看版本

    最简单的命令 lsb_release -a 查看机器名 hostname 查看内核版本 uname -r 红帽 centos 查看版本 cat /etc/redhat-release ubuntu 查 ...

  8. panda迭代

    1.注意 - 不要尝试在迭代时修改任何对象.迭代是用于读取,迭代器返回原始对象(视图)的副本,因此更改将不会反映在原始对象上. 2.itertuples()方法将为DataFrame中的每一行返回一个 ...

  9. fullstack

    fullstack https://www.fullstack.io/ https://www.fullstack.io/write-a-book https://github.com/fullsta ...

  10. BZOJ1195[HNOI2006]最短母串——AC自动机+BFS+状态压缩

    题目描述 给定n个字符串(S1,S2,„,Sn),要求找到一个最短的字符串T,使得这n个字符串(S1,S2,„,Sn)都是T的子串. 输入 第一行是一个正整数n(n<=12),表示给定的字符串的 ...