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: