develooper Front page | | Postings from March 2002

Perl Tip 6: Install modules from CPAN

Ask Bjoern Hansen
March 8, 2002 18:03
Perl Tip 6: Install modules from CPAN
Message ID:

To give feedback on this tip, please go to

One of the things that makes Perl so great is the vast selection of
readily available modules.  With Perl you rarely have to reinvent the
wheel to talk to network servers, calculate dates, use databases,
parse HTML and hundreds if not thousands of other things.

The standard way to install a module is a bit different if you use
Unix or Windows.

(scroll down for unix instructions)

For Windows

If you use Perl under CygWin, the instructions for Unix apply.

If you use ActiveState's ActivePerl then your best option is to use
the "ppm" (Programmer's Package Manager) tool.

ppm can be run by typing ppm in a command prompt window.  To install
the MP3::Info module type

   install MP3::Info

After installing you can at a command prompt run

   perldoc MP3::Info

to read the documentation for the newly installed module.

In the ppm shell, try also


to see a listing of modules, or

   search MP3

to search for MP3 related modules.

To learn more about ppm go to

ppm has loads of features, and there's a beta of "ppm3" too you might
want to check out.

For Unix

You need to have various development tools installed to install
modules the standard way with

To get started, you need to be able to run commands as the owner of
your Perl files (usually root).  It is also possible to install
modules as a different user if you don't have write access to the
system wide Perl installation.  The process takes a bit more work and
will be covered in a later tip.

Anyway, when you have logged in (or su'ed) to the user owning the perl
files, run the command

   perl -MCPAN -e shell

Often there's a small script installed with the name "cpan" that does
the same thing, if so you can just run that.

The first time you run the CPAN shell you'll have to configure it.
It'll interactively ask you a bunch of questions, each time providing
a reasonable default.  On most systems you'll be able to just press
enter all the way through, except for choosing some nearby mirrors.

When you are through the configuration you are ready to install a

At the CPAN shell prompt you are now ready to install a module, type

  install MP3::Info

to download the latest version, compile it, test it and install it.
If the module includes regression tests, will run those and
not install the module if they fail.  By using "force install" instead
of "install" you can override this, if you are sure the failures won't
affect you.

After you leave the CPAN shell (with the 'quit' command) you can type
"perldoc MP3::Info" to read the documentation for your newly installed

A few other useful commands in the CPAN shell are

  i /mp3/        - search for all modules with /mp3/ in the name
  i MP3::Info    - show information about this module
  look MP3::Info - download a module and start a subshell where you
                   can look around before installing
  readme MP3::Info - show the readme file for the module
  ?              - show command summary

Another tip is that you can install stuff without actually starting
the CPAN shell; just run

  perl -MCPAN -e 'install "MP3::Info"'

(of course substitute MP3::Info with the module you want to install).

For the full reference, run "perldoc CPAN" at your prompt or go to

To unsubscribe: mail
To subscribe: mail
Or visit:

Comments, suggestions? Send them to
or via Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About