If doing Perl programming or if another package requires a Perl module, learning how to install one may become necessary. The recommended way to install a Perl module is through the distribution’s repositories, however, they can be installed manually with Perl.
Perl has its own repository where programmers make available their modules called the comprehensive Perl archive network, which is better known as the CPAN. Perl includes a built-in module that can download, build, and install from the network. For some distributions this module may already be built, however, it is probably a good idea for all to build it… to be sure it is set up correctly. Begin by starting the CPAN module shell so that it may be configured:
perl -MCPAN -e shell
A configuration message will appear… most users will be good with the automatic configuration it recommends. If additional configuring needs to be done later typing
o conf init will re-run the configuration dialog. To leave the shell type
The first requirement most people will need to do is build and/or update the CPAN module. Modules can be installed with the built-in module in three ways: from the module shell, from the
perl command, or from the CPAN module binary.
From the shell (which was entered in the configuration section), the following command will install a new module, or in this case, update the CPAN module:
perl -MCPAN -e 'install HTML::Template'
cpan module binary:
Note: CPAN itself recommends using the cpanm module for installation. Modules will need to be reloaded after being updated:
Modules are sometimes executable binaries and if they are known to the shell can be executed like any other command. Some modules are support modules and can only be used for programming or by use of another module. Information of installed modules can be discovered with the command
Module maintenance is typically unexpected after installation and the built-in CPAN module has no ability to be able to do so. If the
cpanm module is installed it does have the ability with the
--uninstall/-U option. It will display the files to be removed and prompt for approval before uninstalling.