Skip to content

Instantly share code, notes, and snippets.

@darkn3rd
Last active April 4, 2025 07:11
Show Gist options
  • Save darkn3rd/238d1d270486e526faede6d70a7ec0c5 to your computer and use it in GitHub Desktop.
Save darkn3rd/238d1d270486e526faede6d70a7ec0c5 to your computer and use it in GitHub Desktop.
Perl CPAN vs. CPANM

What is the difference between cpan and cpanm?

This was explanation by Grant McLean

CPAN CLI

cpan the CPAN shell has been shipped with Perl since about 1997. When you run it the first time it asks a bunch of questions and saves the answers in a config file. Then you can install a module by running:

cpan -i Module::Name

The shell provides other commands for searching CPAN and looking inside distribution files.

CPAN PLUS

A project to create a newer, better and more featureful CPAN shell called CPANPLUS (cpanp from the command-line) was started by Jos Boumans, but it was never quite completed to the point where the original vision had been realised.

cpanp i Module::Name

CPAN MINUS

Meanwhile MIYAGAWA decided that cpanp was trying to do too much and what the world really needed was a simpler shell that did less and asked fewer questions (ideally none at all). He created App::cpanminus which provides the cpanm command and does exactly what he intended. You can use it to install a module (and all the module's dependencies) with a command like:

cpanm Module::Name

The main difference between the two is that if you have Perl you should already have the cpan command. Whereas you won't have cpanm unless/until you install it.

INSTALLING CPANM

CPAN

cpan -i App::cpanminus

CURL

System Perl:

curl -L http://cpanmin.us | perl - --sudo App::cpanminus

User Perl (plenv, perlbrew)

curl -L https://cpanmin.us | perl - App::cpanminus

HOMEBREW ON MACOSX

brew install cpanm

REFERENCE

@rsindlin
Copy link

rsindlin commented Dec 3, 2024

Of note, CPAN themselves recommends using cpanm for module installation. From https://www.cpan.org/modules/INSTALL.html:

Install cpanm to make installing other modules easier (you'll thank us later).

I'd say that's also a pretty significant difference between CPAN and cpanm. For a user interface, cpanm is far more user friendly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment