How to install the Perl module from CPAN

Source: Internet
Author: User

How to install the Perl module from CPAN

Perl has a mechanism to import Perl modules from the outside. Modules imported from the outside can be applied to Perl scripts. CPAN is a powerful public Perl module repository contributed by Perl developers all over the world. Because Perl itself has a small number of core Perl modules, you need to install additional Perl modules from CPAN.

You can find any Perl module you want on CPAN. Once you know the name of the Perl module you want to install (for example, HTML: Template), you can install them as follows.

First, check that your computer has installed the C compiler (for example, the GCC compiler ). Because the vast majority of Perl modules are written in the Perl language, some use the C language to implement the underlying layer and then use the XS language for interaction. Therefore, you must install the development environment of Linux C.

Next, open a CPAN interactive interpreter and use the following method to create and install the Perl module.

$ sudo perl -MCPAN -e shellcpan> install HTML::Template

Alternatively, you can use this method.

$ sudo perl -MCPAN -e 'install HTML::Template'

If the above Command sends the "Can't locate CPAN. pm in @ INC" error message, you should first think of using the standard Linux Package Manager Command to install CPAN

For CentOS, Fedora or RHEL:

$ sudo yum -y install perl-CPAN

For Ubuntu and Debian:

$ sudo apt-get install perl-modules

You should be able to useperl -MPCANCommand to manage other Perl modules.

Considering that some people will use the proxy server, they may need to use CPAN on the proxy server. You can use the CPAN console to configure your proxy server.

$ sudo perl -MCPAN -e shellcpan> o conf init /proxy/

After the preceding command is executed, you will be asked to set up your proxy server. Finally, the system will ask you to confirm whether your configuration is complete.

Click here to view the original article

Translator: penguins in Madagascar want to know the author. Visit the linux community.

Feedback address: mdjsjdqe@foxmail.com

This article is sincerely contributed by the original translation Group of the help translation team

This article permanently updates the link address:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.