The short form is just "cpan Chocolate::Belgian" from the command line :)
– brian d foySep 27 '08 at 18:56

3

IIRC the latest ActivePerl no longer has command-line ppm, it now opens a fancy GUI.
– KevNov 8 '08 at 17:18

6

Just "ppm" opens the GUI, but followed by commands it stays at the command line. So, "ppm help", "ppm install ...", etc.
– Bill RuppertApr 13 '12 at 22:40

Cpan command line also works on cygwin under windows.
– TrueYApr 25 '13 at 18:58

3

@MatthewLock: ppm uses hyphens - because you specify the distribution that you want to install, which is a lot more honest. For instance, if you use cpan to install LWP, LWP::Simple or LWP::UserAgent it will install the distribution libwww-perl for you. The majority of distributions contain a single module with an equivalent name, but there are several exceptions like that
– BorodinJun 10 '14 at 21:52

It's great for just getting stuff installed. It provides none of the more complex functionality of CPAN or CPANPLUS, so it's easy to use, provided you know which module you want to install. If you haven't already got cpanminus, just type:

# cpan App::cpanminus

to install it.

It is also possible to install it without using cpan at all. The basic bootstrap procedure is,

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

For more information go to the App::cpanminus page and look at the section on installation.

Using cpan to install App::cpanminus is a bit odd. The normal install instructions involve a bootstrapping procedure of downloading a part of it from cpanmin.us and using that to install the rest. This avoids the configuration of cpan and the creation of a (thereafter) useless .cpan directory.
– Chas. OwensJul 9 '11 at 0:35

On Ubuntu, you can just install cpanminus from terminal. I find cpanm better than cpan because it doesn't put error logs on screen rather stores them in temporary log files and gives the path in case of errors.
– user13107Sep 2 '16 at 7:42

I note some folks suggesting one run cpan under sudo. That used to be necessary to install into the system directory, but modern versions of the CPAN shell allow you to configure it to use sudo just for installing. This is much safer, since it means that tests don't run as root.

If you have an old CPAN shell, simply install the new cpan ("install CPAN") and when you reload the shell, it should prompt you to configure these new directives.

Nowadays, when I'm on a system with an old CPAN, the first thing I do is update the shell and set it up to do this so I can do most of my cpan work as a normal user.

Also, I'd strongly suggest that Windows users investigate strawberry Perl. This is a version of Perl that comes packaged with a pre-configured CPAN shell as well as a compiler. It also includes some hard-to-compile Perl modules with their external C library dependencies, notably XML::Parser. This means that you can do the same thing as every other Perl user when it comes to installing modules, and things tend to "just work" a lot more often.

@Lao Tzu: no, as CPAN is Perl core module and is not available as separate DEB package. I think in most situations is even better to use App::cpanminus, it is such a joy to use it. Philip Potter suggest it in his answer here and you could try this Chas. Owens answer.
– w.kMar 22 '11 at 16:03

This will give you a deb package that you can install to get Some::Random::Module. One of the big benefits here is man pages and sample scripts in addition to the module itself will be placed in your distro's location of choice. If the distro ever comes out with an official package for a newer version of Some::Random::Module, it will automatically be installed when you apt-get upgrade.

On Fedora Linux or Enterprise Linux, yum also tracks perl library dependencies. So, if the perl module is available, and some rpm package exports that dependency, it will install the right package for you.

Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).