User Tools

Site Tools


tutorials:perl_cpan

Using the Comprehensive Perl Archive Network (CPAN)

CPAN

  • CPAN is a large collection of perl modules.

Installing modules

To call the CPAN shell interface, use:

$ sudo perl -MCPAN -e shell

Using sudo allows for system-wide installation of new modules. When the call is successful, you should see a shell interface:

cpan[1]> 

For example, if we want to install bioperl, first we can do a listing with the following command:

cpan[1]> d /bioperl/

This should generate some output similar to the following:

CPAN: Storable loaded ok (v2.20)
Going to read '/home/chkuo/.cpan/Metadata'
  Database was generated on Thu, 08 Jul 2010 06:27:10 GMT
Distribution    BIRNEY/bioperl-1.2.2.tar.gz
Distribution    BIRNEY/bioperl-1.2.3.tar.gz
Distribution    BIRNEY/bioperl-1.2.tar.gz
Distribution    BIRNEY/bioperl-1.4.tar.gz
Distribution    BIRNEY/bioperl-db-0.1.tar.gz
Distribution    BIRNEY/bioperl-ext-1.4.tar.gz
Distribution    BIRNEY/bioperl-gui-0.7.tar.gz
Distribution    BIRNEY/bioperl-run-1.4.tar.gz
Distribution    BOZO/Fry-Lib-BioPerl-0.15.tar.gz
Distribution    CJFIELDS/BioPerl-1.6.0.tar.gz
Distribution    CJFIELDS/BioPerl-1.6.1.tar.gz
Distribution    CJFIELDS/BioPerl-db-1.6.0.tar.gz
Distribution    CJFIELDS/BioPerl-network-1.6.0.tar.gz
Distribution    CJFIELDS/BioPerl-run-1.6.1.tar.gz
Distribution    CRAFFI/Bundle-BioPerl-2.1.8.tar.gz
15 items found

From this list, we can see that the CJFIELDS/BioPerl-1.6.1.tar.gz module is what we want (the newest version). To install:

cpan[2]> install CJFIELDS/BioPerl-1.6.1.tar.gz

Usually this should work for most modules and all required dependencies should be installed automatically. Bioperl is unusual because it contains a large number of components and some tests may fail during the installation process. Often these failures do not really matter and we can proceed with force install:

cpan[3]> force install CJFIELDS/BioPerl-1.6.1.tar.gz
tutorials/perl_cpan.txt · Last modified: 2012/03/01 14:02 by chkuo