zoukankan      html  css  js  c++  java
  • Perl模块的三种安装方法

    一般来说,安装perl模块常见有源码、CPAN命令、包管理工具等三种方法,本文以安装Net::Telnet模块为例,简单的介绍一下这三种方法。

    第一种,直接去CPAN官网下载源码包安装,详细的安装方法等,请参照解压目录下的README或者INSTALL文件:

    ?
    1
    2
    3
    4
    5
    6
    [root@test~]# wget http://search.cpan.org/CPAN/authors/id/J/JR/JROGERS/Net-Telnet-3.03.tar.gz
    [root@test~]# tar -xzvf Net-Telnet-3.03.tar.gz
    [root@test~]# cd Net-Telnet-3.03
    [root@testNet-Telnet-3.03]# perl Makefile.PL
    [root@testNet-Telnet-3.03]# make && make test
    [root@testNet-Telnet-3.03]# make install


    在有的模块的安装过程中,可能会询问一些设置情况,根据你的实际情况选择。
    注意,如果源码包安装过程中出现了依赖别的模块的情况,需要先安装依赖的模块,所以源码安装有时候比较麻烦。

    第二种,用cpan命令在线安装,安装的时候模块名一定要正确:
    1.首先安装一些cpan需要的一些小工具:

    ?
    1
    [root@test~]# yum -y install unzip links ftp make wget gpg

    2.然后开始用cpan命令安装,第一次用cpan命令会有很多要设置的,为了简单,除了下面列出来的,其他的我都采用默认,直接回车(更推荐你仔细阅读每一步的提示信息,根据实际情况而进行相应的选择):

    ?
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    [root@test~]# cpan install Net::Telnet
    ......前略......
    First, pick a nearby continent and country (you can pick several of
    each, separated by spaces, or none ifyou just want to keep your
    existing selections). Then, you will be presented with a list of URLs
    of CPAN mirrors inthe countries you selected, along with previously
    selected URLs. Select some of those URLs, or just keep the old list.
    Finally, you will be prompted forany extra URLs -- file:,ftp:, or
    http: -- that host a CPAN mirror.
     
    (1) Africa
    (2) Asia
    (3) Central America
    (4) Europe
    (5) North America
    (6) Oceania
    (7) South America
    Select your continent (or several nearby continents) [] 2 <----选择你所在的大区域(洲),然后回车
    Sorry! since you don't have any existing picks, you must makea
    geographic selection.
     
    (1) Bangladesh
    (2) China
    (3) Hong Kong
    (4) India
    (5) Indonesia
    (6) Israel
    (7) Japan
    (8) Kazakhstan
    (9) Pakistan
    (10) Republic of Korea
    (11) Russia
    (12) Saudi Arabia
    (13) Singapore
    (14) Taiwan
    (15) Thailand
    (16) Turkey
    Select your country (or several nearby countries) [] 7 <----选择你所在的国家,然后回车
    Sorry! since you don't have any existing picks, you must makea
    geographic selection.
     
    (1)ftp://ftp.dti.ad.jp/pub/lang/CPAN/
    (2)ftp://ftp.jaist.ac.jp/pub/CPAN/
    (3)ftp://ftp.kddilabs.jp/CPAN/
    (4)ftp://ftp.nara.wide.ad.jp/pub/CPAN/
    (5)ftp://ftp.riken.jp/lang/CPAN/
    (6)ftp://ftp.ring.gr.jp/pub/lang/perl/CPAN/
    (7)ftp://ftp.u-aizu.ac.jp/pub/CPAN/
    (8)ftp://ftp.yz.yamagata-u.ac.jp/pub/lang/cpan/
    Select as many URLs as you like (by number),
    put them on one line, separated by blanks, e.g. '1 4 5' [] 2 4 5 <----选择你所在的模块下载ftp站点,然后回车
    ......前略......

    初次运行CPAN时需要做一些设置,如果您的机器是直接与因特网相联(拨号上网、专线,etc.),那么一路回车就行了,只需要在最后一步选一个离您最近的 CPAN 镜像站点。例如我选的是位于国内的ftp://www.perl87.cn/CPAN/ 。否则,如果您的机器位于防火墙之后,还需要设置ftp代理或http代理。下面是常用 ppm 命令。

      获得帮助
      cpan>help

      列出CPAN上所有模块的列表
      cpan>m

      安装模块,自动完成Net::Server模块从下载到安装的全过程。
      cpan>install Net::Server

      退出
      cpan>quit

      C、使用CPAN模块自动安装方法二:

      cpan -i 模块名

      例如:cpan -i Net::Server

      几个主要的CPAN站点有:

      国内:

      最新更新请查阅 http://cpan.org/SITES.html

      http://www.perl87.cn/CPAN/  网页镜像
      ftp://www.perl87.cn/CPAN/   模块镜像
      
      国外:

      http://www.cpan.org/


    第三种,最简单的方法,使用yum安装:

    ?
    1
    [root@test~]# yum -y install perl-Net-Telnet

    但是只有yum源里有的perl模块,才可以通过这种方式安装,所以并不适合所有perl模块。为了让你的yum软件仓库里能有更多常用的软件,建议你除了官方的yum源外,再追加配置EPEL和rpmforge等常见且可以信赖的yum源。

  • 相关阅读:
    HTML5中表单的创建
    防冲撞协议原理实验报告
    yii2.0 Activeform表单部分组件使用方法 [ 2.0 版本 ]
    Yii正则验证
    Yii2用Gii自动生成Module+Model+CRUD
    yii2框架安装运行init.bat报错php.exe不是内部或外部命令
    YII2.0安装教程,数据库配置前后台 [ 2.0 版本 ]
    ignore_user_abort函数制定计划任务
    php 常用的系统函数
    php常用字符串处理函数
  • 原文地址:https://www.cnblogs.com/xiaomaohai/p/6157768.html
Copyright © 2011-2022 走看看