当我们想使用某些Perl模块的时候,很可能会遇到当前系统不存在这个模块的情况,这时我们可以通过使用CPAN来对相应的模块进行获取,下面就介绍一下CPAN的使用方法。
首先,我们可以用perl -e 'use module'这个命令来检查一下系统的perl的某个模块是否可用,如
[root@localhost ~]# perl -e 'use Test::Parser'
Can't locate Test/Parser.pm in @INC (......更多报错信息自动略过) at -e line 1.
BEGIN failed--compilation aborted at -e line 1.
根据显示我们知道系统上没有Test::Parser这个模块,因此我们需要使用CPAN进行安装,因此下面我们进入CPAN。
[root@localhost ~]# perl -MCPAN -e shell
Can't locate CPAN.pm in @INC (......).
BEGIN failed--compilation aborted.
此时进入CPAN失败,原因很简单,系统没有包含CPAN,所以我们需要首先安装CPAN,方法如下(本人使用的是Fedora 8,其他系统请对号入座):
[root@localhost ~]# yum install perl-CPAN
updates-newkey                                           | 2.3 kB     00:00    
fedora                                                   | 2.1 kB     00:00    
updates                                                  | 2.6 kB     00:00    
设置安装进程
分析安装参数的语法
解决依赖相关
-->运行处理检查
---> 包 perl-CPAN.i386 0:1.76_02-41.fc8 设置为 升级
--> 完成依赖性检查
依赖性解决
================================================================================
 包               架构        版本                  仓库                   大小
================================================================================
正在安装:
 perl-CPAN        i386        1.76_02-41.fc8        updates-newkey        129 k
Transaction Summary
================================================================================
Install      1 Package(s)        
Update       0 Package(s)        
Remove       0 Package(s)        
总共下载大小: 129 k
确定是这样吗? [y/N]: y
下载软件包:
perl-CPAN-1.76_02-41.fc8.i386.rpm                        | 129 kB     00:02    
============================== Entering rpm code ===============================
运行 rpm_check_debug
运行测试事务处理
传输测试完成
事务处理测试成功
运行事务处理
  正在安装       : perl-CPAN                                                1/1
=============================== Leaving rpm code ===============================
已安装:
  perl-CPAN.i386 0:1.76_02-41.fc8                                              
恭喜你!成功完成!
这时我们就完成了perl-CPAN的安装,再次使用刚才的命令进入CPAN。
[root@localhost ~]# perl -MCPAN -e shell
/usr/lib/perl5/5.8.8/CPAN/Config.pm initialized.
CPAN is the world-wide archive of perl resources. It consists of about
100 sites that all replicate the same contents all around the globe.
Many countries have at least one CPAN site already. The resources
found on CPAN are easily accessible with the CPAN.pm module. If you
want to use CPAN.pm, you have to configure it properly.
If you do not want to enter a dialog now, you can answer 'no' to this
question and I'll try to autoconfigure. (Note: you can revisit this
dialog anytime later by typing 'o conf init' at the cpan prompt.)
Are you ready for manual configuration? [yes]
因为是首次使用cpan所以系统需要配置一下环境参数,可以直接选择no.
cpan> reload cpan        # 更新CPAN
在完成以上步骤后,就可以用install module 来安装需要的模块了
[root@localhost ~]# cpan> install Test::Parser
如果最后显示OK的话,则该模块可以使用了,这一点可以通过第一步的命令进行检查。

原文链接:http://blog.sina.com.cn/s/blog_48c95a190100h7yq.html

Linux CPAN Perl 模块安装的更多相关文章

  1. Linux下perl模块安装

    perl模块下载地址: http://search.cpan.org/ 假设放在/usr/local/src/下 cd /usr/local/src 上传下载的压缩包CGI-Session-3.95. ...

  2. perl模块安装

    转自: http://www.cnblogs.com/itech/archive/2009/08/10/1542832.html http://www.mike.org.cn/blog/index.p ...

  3. Linux下Perl的安装(转)

    原文地址:Linux下Perl的安装 今天在虚拟机测试shell脚本的时候,有些命令使用不了. 比如说 mysqlhotcopy ,它提示Perl的版本太低. 我用的 RedHat9 的Perl才5. ...

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

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

  5. perl 模块安装

    You can check if you have them installed in your machine with: > perl -e 1 -M<module> It wi ...

  6. ---perl 模块安装方法

    http://blog.csdn.net/lincy100/article/details/7333794 $ perl -MCPAN -e shell install Log::Log4perlin ...

  7. perl模块安装——cpanm

    下载 wget  http://xrl.us/cpanm mv cpanm.1 cpanm 配置 在bashrc或zshrc里面加入下面的几句话 最好把相对路径改成绝度路径(将~换成你根目录的绝对路径 ...

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

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

  9. 非[无]root权限 服务器 下安装perl以及perl模块--转载

    转载自http://www.zilhua.com 在本博客中,所有的软件安装都在服务器上,且无root权限.理论上适合所有的用户. 我的安装目录 cd /home/zilhua/software 1. ...

随机推荐

  1. 第六百一十一天 how can I 坚持

    离开泛华了,在那感觉确实挺压抑的,什么环境才适合我呢.哎. 明天回济南,弟弟交房了,去看看房子,和郭娜跨个年,好好谈吧,尽快结婚了. 睡觉.

  2. 使用用Generic.xaml加载默认的主题资源

    把Resource嵌入到Generic.xaml文件中,并把该文件放到应用程序的Themes主题文件夹下面,这们Generic.xaml文件中的资源就可以被系统识别为默认主题一部分,从而进行使用. 为 ...

  3. 如何理解JS回调函数

    1.回调函数英文解释: A callback is a function that is passed as an argument to another function and is execut ...

  4. 修改C# 新建类模板

    找到安装路径下的这个文件夹:D:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\ItemTemplatesCache\CSh ...

  5. MySQL for Visual Studio Version

    MySQL for Visual Studio Version Connector/Net Version Supported Visual Studio Version Supported MySQ ...

  6. C语言深度挖掘

    二级指针和回调函数的用法: #include <stdio.h> #include <stdlib.h> int add(int num1 ,int num2){ return ...

  7. 笔记9-徐 DBCC SHRINKFILE不起作用的原因

    1 , , , , , , , , ,40) ,1 page_id pg_alloc ext_size obj_id index_id partition_number partition_id ia ...

  8. hg常用命令

    关于hg命令选项 如果你是在windows系统下,使用的是图像界面,你很可能不常用它.但是一旦你了解这些命令之后,会觉得很方便.hg有很多命令,这些命令都有一定的选项,在开始的时候,只知道用它,有时候 ...

  9. 清空表数据 mysql让主键从1开始

    TRUNCATE TABLE name 删除表中的所有行,而不记录单个行删除操作.

  10. Java堆、栈和常量池以及相关String的详细讲解(经典中的经典) (转)

    原文链接 : http://www.cnblogs.com/xiohao/p/4296088.html 一:在JAVA中,有六个不同的地方可以存储数据: 1. 寄存器(register). 这是最快的 ...