5.1 CPAN安装perl包


The Comprehensive Perl Archive Network (CPAN in short) is a popular central repository of currently 188,714 Perl modules in 40,986 distributions. It is a single location where you can find, download and install any of the incredible (and still growing) collection of Perl libraries.

It has 25,000 modules available and it is mirrored on servers around the world. It also supports automated testing: cross-platform and on multiple versions of Perl, and bug tracking for every library. Also, you can search it using various sites on the web, which offer tools such as grep, version-to-version diff as well as documentation.

The CPAN Perl module is a core module that allows you to query, download, build and install Perl modules and extensions from CPAN sites. It has been distributed with Perl since 1997 (5.004). It includes some primitive searching capabilities and supports named and versioned bundles of modules.

In this article, you will learn how to install Perl and Perl modules in CentOS 8 using CPAN.

一、CentOS 8安装CPAN

dnf install perl-CPAN
dnf install "@Development Tools"

Note: Although most Perl modules are written in Perl, some use XS – they are written in C and so require a C compiler which is included in the Development Tools package.


2.1 安装

To install Perl modules using CPAN, you need to use the cpan command-line utility. You can either run cpan with arguments from the command-line interface, for example, to install a module (e.g Geo::IP) use the -i flag as shown.

# cpan -i Geo::IP
# cpan Geo::IP  

When you run cpan for the first time, it requires configuration as shown in the screenshot below. For this guide, we will enter yes to configure it automatically. If you enter no, the configuration script will take you through a series of questions to configure it.

Alternatively, you can run a cpan without arguments to start CPAN.pm shell. Then use the install sub-command to install a module (e.g Log::Log4perl) as shown.

cpan[1]> install Log::Log4perl

2.2 查看已安装的模块

# cpan -l

2.3 查看已安装的perl模块的信息

# cpan
cpan[1]> m Net::Telnet
cpan[1]> m HTML::Template

2.4 查看更多功能

# man cpan
# cpan
cpan[1]> help

三、 CPANM安装perl模块

# cpan App::cpanminus


# cpanm git://github.com/miyagawa/Starman.git


man cpanm


个人公众号,比较懒,很少更新,可以在上面提问题,如果回复不及时,可发邮件给我: tiehan@sina.cn