zoukankan      html  css  js  c++  java
  • Linux CPAN Perl 模块安装

    当我们想使用某些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

  • 相关阅读:
    精彩源于起点——2018年潍坊市首次青少年Python编程公开课
    第一款Micropython图形化编辑器—Python Editor
    [Micropython]TPYBoard v10x拼插编程实验 点亮心形点阵
    Android-Notification通知Demo
    Android-Handler更新View加线程
    Android-Handler更新View
    Android-Service开发步骤
    Android-高级UI控件_TabHost标签组件
    Android-高级UI控件_SeekBar拖动条
    Android-高级UI控件_ProgressDialog进度条对话框
  • 原文地址:https://www.cnblogs.com/cade/p/3654733.html
Copyright © 2011-2022 走看看