[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Perl Tip 6: Install modules from CPAN
- To: <tips@perl.org>
- Subject: Perl Tip 6: Install modules from CPAN
- From: Ask Bjoern Hansen <ask@perl.org>
- Date: Fri, 8 Mar 2002 18:01:22 -0800 (PST)
- Delivered-To: mailing list tips@perl.org
- Delivered-To: moderator for tips@perl.org
- Mailing-List: contact tips-help@perl.org; run by ezmlm
To give feedback on this tip, please go to
http://learn.perl.org/tips/feedback/tip6
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
search
to see a listing of modules, or
search MP3
to search for MP3 related modules.
To learn more about ppm go to
http://aspn.activestate.com/ASPN/Products/ActivePerl/faq/ActivePerl-faq2.html
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 CPAN.pm.
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
module.
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, CPAN.pm 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
module.
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
http://perldoc.perl.org/cpan.html
(original link http://www.perldoc.com/perl5.6.1/lib/CPAN.html broken)
To unsubscribe: mail tips-unsubscribe@perl.org
To subscribe: mail tips-subscribe@perl.org
Or visit: http://learn.perl.org/tips/
Comments, suggestions? Send them to ask@perl.org
or via http://learn.perl.org/tips/feedback/tip6