Perl (Scripting) - Install a module using cpan

by
Jeremy Canfield |
Updated: October 06 2022
| Perl (Scripting) articles
cpan (this article) or cpanm can be used to install a Perl module.
- Install a module using cpanm
- Install a module using cpan (this article)
Before installing a module, you may want to use the perldoc command to determine if the module is installed.
perldoc -l Net::SSH:Perl
Or this command.
perl -MNet::SSH::Perl -e 'print $INC{"Net/SSH/Perl.pm"}'
On a Red Hat Distribution (CentOS, Fedora, Red Hat), the dnf install or yum install command can be used to install cpan.
dnf install perl-CPAN
Start the cpan interactive prompt.
cpan
Then, use the install module_name (or force install) command to install a module. In this example, the SSH module is installed.
cpan> install Net::SSH::Perl
If the install fails, you can try with the force option.
cpan> force install Net::SSH::Perl
Did you find this article helpful?
If so, consider buying me a coffee over at