Yuki Kimoto
Posted on April 8, 2022
cpanm is a command line tool to install CPAN modules on user directories.
This article is originally cpanm - Installation of Perl Modules on User Directories | Perl ABC
# Installation of CPAN modules cpanm MoudleName
Installation of cpanm
Explains how to install cpanm.
Strawberry Perl
Strawberry Perl has cpanm by default. Strawberry Perl is one of Perl distributions on Windows.
perlbrew
If you install perlbrew, you can install cpanm in the following command.
perlbrew install-cpanm
plenv
If you install plenv, you can install cpanm in the following command.
plenv install-cpanm
Download cpanm itself
You can download cpanm itself.
curl -L -O http://xrl.us/cpanm > cpanm chmod 755 cpanm
You can execute cpanm as the following.
./cpanm ModuleName
Package Managers
Install cpanm using package managers.
apt install cpanminus
yum install perl-App-cpanminus
Install CPAN Modules
Install CPAN modules using cpanm.
# Install CPAN modules. cpanm Mojolicious
Version Specific
You can install modules with the version.
cpanm Mojolicious@9.23
Specifying the installation directory
You can install CPAN modules on the specified directory using -L option.
cpanm -L extlib DBIx::Custom
DBIx::Custom will be installed "extlib" in the current directory.
cpanfile - Definition of Modules
You can defined modules you want to install and the versions using cpanfile.
Writing cpanfile
cpanfile is a file to define the modules and the versions.
Create the file "cpanfile".
# Create a "cpanfile" file touch cpanfile
Define the moudles and the versions.
requires 'DBI', '== 1.619'; requires 'DBD::SQLite', '== 1.36_04'; requires 'DBIx::Custom', '== 0.25';**cpanfile formats:**
requires MODULE_NAME VERSION
You can use the following syntax for the version:
Descriptions | Formats | Examples |
Specified version | == Version | == 0.03 |
Specified version or higher | >= Version | >= 0.03 |
Below the specified version | <= Version | <= 0.03 |
Greater than the specified version | > Version | > 0.03 |
Less than the specified version | < Version | < 0.03 |
Install Modules using cpanfile
You can install CPAN modules from the definition of cpanfile using the "--installdeps" option.
# Install CPAN modules from the definition of cpanfile perl cpanm --installdeps .
You can also install modules on the specified directory using the "-L" option.
perl cpanm -L extlib - installdeps.
Showing Help
Show the cpanm help.
cpanm -h
Posted on April 8, 2022
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.