cpan安装及其使用

Perl是一种相当灵活的程序编程语言,现有的许有程序都是使用它进行编程的。它的优点之一就是无需自己编写编码,你就能利用许多增加的模块,创建新的功能。

  程序利用这些模块的编码,而程序员就能集中开发编码,无需担心大量的工作量。但是,你必须在Perl程序运行之前安装任何特定的模块。
  虽然许多Linux零售商创建了各种Perl模块的RPM软件包,但他们并不为每一个现存的模块创建数据包,除了那些是供应商所要求的。这就是Comprehensive Perl Archive Network (CPAN)的产生的原因。
  使用CPAN模块,你就能使用Perl本身安装其它模块。这样做,你就需要你所要安装的模块的名字。比如,你要安装的是Time::HiRes或是DBI模块。具有特色的是,如果你为一个特定的Perl程序查看README文件,它将会列举任何所要求的模块的名字。

第一: 安装:

  使用CPAN,成为根用户,执行以下操作:
  # perl -MCPAN -e shell
  首次这样做的话,你就必须配置CPAN模块。花一些时间按照提示回答它所问的问题;网上通常有这样的例子,通常情况下,问题按住【Enter】就可。这里是说通常情况下,最好自己设置一下!
*************************************************************************************************************

第二:重新设置:
       如果在初始安装完成以后,您再想修改某些设置,可以通过以下两种方法进行设置:

方法1:shell下输入cpan,然后回车,cpan[1]> o conf init,会出现一下内容:

CPAN is the world-wide archive of perl resources. It consists of about
300 sites that all replicate the same contents 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, lots of things have to be configured. Fortunately, most of
them can be determined automatically. If you prefer the automatic
configuration, answer 'yes' below.

If you prefer to enter a dialog instead, you can answer 'no' to this
question and I'll let you configure in small steps one thing after the
other. (Note: you can revisit this dialog anytime later by typing 'o
conf init' at the cpan prompt.)
Would you like me to configure as much as possible automatically? [yes]
默认的[yes],系统自动的进行编译修改。当然,您可以输入no,回车,然后一项一项的修改。

方法2:修改cpan里面的Config.pm文件
     寻找文件:
[root@localhost ]# find / -name Config.pm
/home/.Trash/perl_moduals/perl-5.10.0/ext/Encode/lib/Encode/Config.pm
/home/soft/perl_moduals/perl-5.10.0/ext/Encode/lib/Encode/Config.pm
/usr/lib/perl5/5.8.8/Net/Config.pm
/usr/lib/perl5/5.8.8/ExtUtils/MakeMaker/Config.pm
/usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/Config.pm
/usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/Encode/Config.pm
/usr/share/automake-1.9/Automake/Config.pm
/usr/local/perl/lib/5.10.0/Net/Config.pm
/usr/local/perl/lib/5.10.0/x86_64-linux/Config.pm
/usr/local/perl/lib/5.10.0/x86_64-linux/Encode/Config.pm
/usr/local/perl/lib/5.10.0/Log/Message/Config.pm
/usr/local/perl/lib/5.10.0/ExtUtils/MakeMaker/Config.pm
/usr/local/perl/lib/5.10.0/Module/Build/Config.pm
/usr/local/perl/lib/5.10.0/CPANPLUS/Config.pm
/usr/local/perl/lib/5.10.0/CPAN/Config.pm
/usr/local/perl/lib/site_perl/5.10.0/HTTP/Config.pm

然后 vi  /usr/local/perl/lib/5.10.0/CPAN/Config.pm

# This is CPAN.pm's systemwide configuration file. This file provides
# defaults for users, and the values can be changed in a per-user
# configuration file. The user-config file is being looked for as
# /root/.cpan/CPAN/MyConfig.pm.

$CPAN::Config = {
  'applypatch' => q[],
  'auto_commit' => q[0],
  'build_cache' => q[100],
  'build_dir' => q[/root/.cpan/build],
  'build_dir_reuse' => q[1],
  'build_requires_install_policy' => q[ask/yes],
  'bzip2' => q[/usr/bin/bzip2],
  'cache_metadata' => q[1],
  'check_sigs' => q[0],
  'colorize_output' => q[0],
  'commandnumber_in_prompt' => q[1],
  'connect_to_internet_ok' => q[1],
  'cpan_home' => q[/root/.cpan],
  'curl' => q[/usr/bin/curl],
  'ftp' => q[/usr/kerberos/bin/ftp],
  'ftp_passive' => q[1],
  'ftp_proxy' => q[],
  'getcwd' => q[cwd],
  'gpg' => q[/usr/bin/gpg],
  'gzip' => q[/usr/bin/gzip],
  'halt_on_failure' => q[0],
  'histfile' => q[/root/.cpan/histfile],
  'histsize' => q[100],
  'http_proxy' => q[],
  'inactivity_timeout' => q[0],
  'index_expire' => q[1],
  'inhibit_startup_message' => q[0],
  'keep_source_where' => q[/root/.cpan/sources],
  'load_module_verbosity' => q[v],
  'lynx' => q[],
  'make' => q[/usr/bin/make],
  'make_arg' => q[],
  'make_install_arg' => q[],
"/usr/local/perl/lib/5.10.0/CPAN/Config.pm" 75L, 2216C
然后修改,保存,退出!

********************************************************************************************************************
第三:使用cpan查询和安装模块(一定在根目录下)

查询:cpan[1]> d /模块名字或者部分名字/
           查询结果中会给出所有含有模块名字或者部分名字的模块,选择您所需要的模块进行下载

下载安装:cpan[1]>  install  模块名字
所有的模块都可以按照上面的例子,类似的进行安装!

cpan安装及其使用的更多相关文章

  1. centos环境下使用CPAN安装perl模块

    首先安装CPAN yum install perl-CPAN 进入cpan环境 perl -MCPAN -e shell 安装模块(以Tk为例) cpan>install Tk 退出 cpan& ...

  2. cpan安装报错Invalid host name on line 1 at *FirstTime.pm line 1857.

    今天鼓捣一下CPAN,安装时出错: root@ubuntu:~# cpan install DBI CPAN.pm requires configuration, but most of it can ...

  3. 修改CPAN安装源

    更新CPAN镜像源的方法,以CentOS 6.5为例. 存储CPAN设置信息的文件路径为: /usr/share/perl/CPAN/Config.pm 使用vi打开文件 vi /usr/share/ ...

  4. Linux下安装与使用本地的perl模块

    转自 http://www.cnblogs.com/xianghang123/archive/2012/08/23/2652806.html Linux下安装与使用本地的perl模块 在使用Linux ...

  5. Perl模块的安装方法

    1. 下载离线安装包 *.tar.gz的形式解包后,#perl Makefile.PL#make#make install 2. 在联网的情况下,通过CPAN安装# perl -MCPAN -e sh ...

  6. 四月二十五日,bugzilla for CentOS 安装

    Bugzilla for CentOS 5.4 制作人,陈浩 时间:2014.4.25 原创 文件夹 Bugzilla for CentOS 5.4 一. 装系统 1) 新建虚拟机  15G硬盘,51 ...

  7. 安装centreon

     Centreon + nagios + ndoutils 安装 2013-09-25 19:42:44 标签:centreon 原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者 ...

  8. pt-query-digest 安装及使用

    打个草稿 介绍:pt-query-digest 可用于mysql的慢查询的日志分析,分析统计出每种慢查询的基本信息,如响应时间.最大执行时间.最小执行时间.执行时间的中位数等.(当然不只是这个功能) ...

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

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

随机推荐

  1. Attempted to lock an already-locked dir的解决方法

    第一,在当前目录使用“清理”功能,如果不行,到上一级目录,再执行“清理”. 第二,如果看到某个包里面的文件夹没有SVN的标志,直接用“Ctrl+Delete”手工删除,然后“清理”.

  2. Yaf-Plus 我们只谈框架这件事

    预热下,也算对自己的督促. Comming soon!

  3. ThinkPHP中ajax提交数据

    最近在做项目时遇到了一些需要从页面用ajax提交数据到后台的操作,无奈本人技术有限,网上苦寻,研究了一下ajax和thinkPHP的结合,黄天不负苦心人,终于搞定了. 闲话少叙,进入正题:我需要从页面 ...

  4. CSS转载备忘

    原文地址:http://www.cnblogs.com/coffeedeveloper/p/3145790.html#html 转载内容: 对CSS中的Position.Float属性的一些深入探讨 ...

  5. [原]CAS和Shiro在spring中集成

    shiro是权限管理框架,现在已经会利用它如何控制权限.为了能够为多个系统提供统一认证入口,又研究了单点登录框架cas.因为二者都会涉及到对session的管理,所以需要进行集成. Shiro在1.2 ...

  6. 接口返回json

    use Mojolicious::Lite; use JSON qw/encode_json decode_json/; # /foo?user=sri get '/api' => sub { ...

  7. Unix/Linux环境C编程入门教程(13) 开发环境搭建VMware软件安装

    VMware(中文名威睿",纽约证券交易所"代码:VMW) 虚拟机软件,是全球桌面到数据中心虚拟化解决方案的领导厂商.全球不同规模的客户依靠VMware来降低成本和运营费用.确保业 ...

  8. (十一年)unity4.6得知Ugui中国文献-------参考-UGUI Visual Components

     大家好,我是太阳广东. 转载请注明出处:http://write.blog.csdn.net/postedit/38922399 更全的内容请看我的游戏蛮牛地址:http://www.unity ...

  9. activemq的两种基本通信方式的使用及总结

    简介 在前面一篇文章里讨论过几种应用系统集成的方式,发现实际上面向消息队列的集成方案算是一个总体比较合理的选择.这里,我们先针对具体的一个消息队列Activemq的基本通信方式进行探讨.activem ...

  10. Java 中的resultset详解

    结果集(ResultSet)是数据中查询结果返回的一种对象,可以说结果集是一个存储查询结果的对象,但是结果集并不仅仅具有存储的功能,他同时还具有操纵数据的功能,可能完成对数据的更新等. 结果集读取数据 ...