最新消息:

Perl模块安装

Perl admin 3613浏览 0评论

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

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

[root@aikaiyuan ~]# wget http://search.cpan.org/CPAN/authors/id/J/JR/JROGERS/Net-Telnet-3.03.tar.gz
[root@aikaiyuan ~]# tar -xzvf Net-Telnet-3.03.tar.gz
[root@aikaiyuan ~]# cd Net-Telnet-3.03
[root@aikaiyuan Net-Telnet-3.03]# perl Makefile.PL
[root@aikaiyuan Net-Telnet-3.03]# make && make test
[root@aikaiyuan Net-Telnet-3.03]# make install

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

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

[root@aikaiyuan ~]# yum -y install unzip links ftp make wget gpg
2.然后开始用cpan命令安装,第一次用cpan命令会有很多要设置的,为了简单,除了下面列出来的,其他的我都采用默认,直接回车(更推荐你仔细阅读每一步的提示信息,根据实际情况而进行相应的选择):
[root@aikaiyuan ~]# cpan install Net::Telnet
......前略......
First, pick a nearby continent and country (you can pick several of
each, separated by spaces, or none if you just want to keep your
existing selections). Then, you will be presented with a list of URLs
of CPAN mirrors in the countries you selected, along with previously
selected URLs. Select some of those URLs, or just keep the old list.
Finally, you will be prompted for any 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 make a
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 make a
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站点,然后回车
......前略......
第三种,最简单的方法,使用yum安装:
[root@aikaiyuan ~]# yum -y install perl-Net-Telnet
但是只有yum源里有的perl模块,才可以通过这种方式安装,所以并不适合所有perl模块。为了让你的yum软件仓库里能有更多常用的软件,建议你除了官方的yum源外,再追加配置EPEL和rpmforge等常见且可以信赖的yum源。

转载请注明:爱开源 » Perl模块安装

您必须 登录 才能发表评论!