• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • vbs
  • DOS/BAT
  • hta/htc
  • python
  • perl
  • VBA
  • ColdFusion
  • ruby
  • PowerShell
  • Lua
  • Golang
  • linux shell
您的位置:首页 > 脚本语言 >perl > cpanm安装及Perl模块安装教程

cpanm安装及Perl模块安装教程

作者:junjie 字体:[增加 减小] 来源:互联网

junjie 通过本文主要向大家介绍了cpanm,安装cpanm,perl模块安装,perl模块,如何安装perl模块等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com

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
</div>

1. 安装cpanm

cpanm其实是一个可执行文件而已。将它下载到bin目录,然后添加执行权限就可以了。

# wget http:
//xrl.us/cpanm -O /usr/bin/cpanm; chmod +x /usr/bin/cpanm
</div>

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
</div>

参数名直接为模块名称

如,安装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
......  //自动解决依赖模块
</div>

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

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

3. 删除模块

安装App::pmuninstall模块:
# cpanm Ap

您可能想查找下面的文章:

  • cpanm安装及Perl模块安装教程

相关文章

  • perl后门,正向和反向!实例代码
  • perl控制流介绍(if条件,while,for循环,foreach)
  • 让apache2以cgi方式运行perl cgi程序的实现方法
  • perl 简明教程 perl教程集合
  • Perl的Mail::POP3Client模块和Gmail通信实例
  • perl如何避免脚本在windows中闪一下就关闭
  • 求婚示爱的Perl代码之注释篇
  • Perl Mysql数据库操作实现代码
  • perl批量查询ip归属地的方法代码
  • fdupe 查找重复文件的Perl脚本代码

文章分类

  • vbs
  • DOS/BAT
  • hta/htc
  • python
  • perl
  • VBA
  • ColdFusion
  • ruby
  • PowerShell
  • Lua
  • Golang
  • linux shell

最近更新的内容

    • perl 调试命令的相关知识小结
    • perl对m x n类似表进行按列排序的代码
    • Perl5 OOP学习笔记第1/2页
    • PERL脚本 学习笔记
    • perl用grep map求交集、并集、补集的实例代码
    • Perl从文件中读取字符串的两种实现方法
    • perl 中文处理技巧
    • Perl一句话命令行编程中常用参数总结
    • 在Perl中使用Getopt::Long模块来接收用户命令行参数
    • Perl中的子程序学习笔记

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有