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. Linux学习之服务器端口查看的方法

    1.用netstat查看: [grid@rac121 admin]$ netstat -anp | grep oracle (Not all processes could be identified ...

  2. nodejs 下载网页及相关资源文件

    功能其实很见简单,通过 phantomjs.exe 采集 url 加载的资源,通过子进程的方式,启动nodejs 加载所有的资源,对于css的资源,匹配css内容,下载里面的url资源 当然功能还是很 ...

  3. 编程工具篇——Vim

    配置 配置文件位于:/etc/vim/vimrc(添加配置在文件末尾输入代码即可) 常用配置 配色方案 :colorscheme ron(其中ron为我的配色方案,也可以选择其他,软件中自带配色文件全 ...

  4. MFC上下浮动与渐入渐出消息提示框实现

    类似QQ与360软件,消息提示有两种.上下浮动.渐入渐出. 1.上下浮动提示框实现 机制,定时器响应上下浮动消息. 主要API:MoveWindow. 源码如下UpDownTipDlg.h.UpDow ...

  5. [LeetCode][Python]Palindrome Number

    # -*- coding: utf8 -*-'''__author__ = 'dabay.wang@gmail.com'https://oj.leetcode.com/problems/palindr ...

  6. Android学习路线(六)为Android应用加入ActionBar

    Action bar 是你可以为你的应用的Activity实现的最为重要的设计元素之中的一个.它提供了集中UI特性.而且通过提供和其它的Android应用的一致性体验让你的应用可以非常快被用户熟悉.基 ...

  7. delphi “Invalid floating point operation.”错误的解决方法

    这两天用webbrower写东西,有时候打开SSL加密站点时会出现”Invalid floating point operation.”的错误,上网搜了下,把解决方法贴上. 导致原因 在Delphi2 ...

  8. objective-c 关键字和概念

    @ 看到这个关键字,我们就应该想到,这是Object-C对C语言的扩展,例如@interface XXX. @interface 声明类 @implementation 实现类 @protocol 声 ...

  9. xcode KVC:Key Value Coding 键值编码

    赋值 // 能修改私有成员变量 - (void)setValue:(id)value forKey:(NSString *)key; - (void)setValue:(id)value forKey ...

  10. param

    页面之间值传递用param作为参数,提高网站安全性