| Article Index |
|---|
| 1. Where to find modules? |
| 2. Install Modules |
| 2.1. Linux Package Mangers |
| 2.2. CPAN Package Archive |
| 2.3. Each Package by Hand |
Perl is a mature programming language, that is great for tasks like text processing and many, many other things. Due to the fact that Perl is a quite old scripting language a lot of modules are available containing things like algorithms implemented in pure Perl or wrappers for native libraries, command line tools or network services.
This article shows you how to find Perl modules and how to integrate them to your system.
1. Where to find modules?
Authors that are interested in providing Perl modules to the public are registering their projects at CPAN. CPAN is the Comprehensive Perl Archive Network. This site provides a lot of information and the opportunity to search for registered modules, authors and distributions.
Perl distributions typically come with the possibility to search in online repositories for new modules. ActiveState, for example, provides an own module manager.
Linux distributions come with a bunch of prepackaged Perl modules. They are searchable and installable by utilizing the package managers of the respective distribution.
Additionally there are a lot of additional resources for Perl modules that may be installed to your systems. In this case you have to perform the installation manually.
2. Install Modules
2.1. Linux Package Mangers
Installing Perl modules by utilizing the primary package manager of your Linux distribution is quite easy. Just start the package manager interface of your choice to search and install software packages. There is no difference between installing Perl modules and other software that is integrated into your Linux distribution.
The following example illustrates how to install Perl modules within Debian based systems.
# install a list of perl modules
$ apt-get install libhtml-parser-perl liburi-perl libmime-perl
As you can see, this is a very easy task! Just try it. If you are willing to remove a Perl module just execute the same command line by replacing the parameter install by remove.
2.2. CPAN Package Archive
You are allowed to download and install Perl modules manually. But if your are installing modules with a lot of dependencies this could be a pain. So Perl provides a feature to install software from CPAN by analysing dependencies between the desired modules. And if you do agree, all the packages are downloaded and installed to your system automatically.
Take a look at the following example to get an idea how this process is working.
# run as root user
$ perl -MCPAN -e 'shell'
cpan> h
Display Information
command argument description
a,b,d,m WORD or /REGEXP/ about authors, bundles, distributions, modules
i WORD or /REGEXP/ about anything of above
r NONE reinstall recommendations
ls AUTHOR about files in the author's directory
Download, Test, Make, Install...
get download
make make (implies get)
test MODULES, make test (implies make)
install DISTS, BUNDLES make install (implies test)
clean make clean
look open subshell in these dists' directories
readme display these dists' README files
Other
h,? display this menu ! perl-code eval a perl command
o conf [opt] set and query options q quit the cpan shell
reload cpan load CPAN.pm again reload index load newer indices
autobundle Snapshot force cmd unconditionally do cmd
# do an update
cpan> install Bundle::CPAN
# install modules
cpan> install Digest::MD5
cpan> install Digest::SHA1
cpan> install HTML::Template
cpan> install Image::Size
cpan> install MIME::Lite
# search for modules with 'a', 'b', 'd', 'm' or 'i'
cpan> m /lorem/
Module = Acme::MetaSyntactic::loremipsum (BOOK/Acme-MetaSyntactic-0.99.tar.gz)
Module Text::Lorem (ADEOLA/Text-Lorem-0.3.tar.gz)
Module Text::Lorem::More (RKRIMEN/Text-Lorem-More-0.12.tar.gz)
Module Text::Lorem::More::Source (RKRIMEN/Text-Lorem-More-0.12.tar.gz)
cpan> i /berlin/
Distribution BEATNIK/Filter-NumberLines-0.02.tar.gz
Module = DateTime::TimeZone::Europe::Berlin (DROLSKY/DateTime-TimeZone-0.7904.tar.gz)
Module Filter::NumberLines (BEATNIK/Filter-NumberLines-0.02.tar.gz)
Author [...]
# run as root user
$ perl -MCPAN -e 'shell'
cpan> h
Display Information
command argument description
a,b,d,m WORD or /REGEXP/ about authors, bundles, distributions, modules
i WORD or /REGEXP/ about anything of above
r NONE reinstall recommendations
ls AUTHOR about files in the author's directory
Download, Test, Make, Install...
get download
make make (implies get)
test MODULES, make test (implies make)
install DISTS, BUNDLES make install (implies test)
clean make clean
look open subshell in these dists' directories
readme display these dists' README files
Other
h,? display this menu ! perl-code eval a perl command
o conf [opt] set and query options q quit the cpan shell
reload cpan load CPAN.pm again reload index load newer indices
autobundle Snapshot force cmd unconditionally do cmd
# do an update
cpan> install Bundle::CPAN
# install modules
cpan> install Digest::MD5
cpan> install Digest::SHA1
cpan> install HTML::Template
cpan> install Image::Size
cpan> install MIME::Lite
# search for modules with 'a', 'b', 'd', 'm' or 'i'
cpan> m /lorem/
Module = Acme::MetaSyntactic::loremipsum (BOOK/Acme-MetaSyntactic-0.99.tar.gz)
Module Text::Lorem (ADEOLA/Text-Lorem-0.3.tar.gz)
Module Text::Lorem::More (RKRIMEN/Text-Lorem-More-0.12.tar.gz)
Module Text::Lorem::More::Source (RKRIMEN/Text-Lorem-More-0.12.tar.gz)
cpan> i /berlin/
Distribution BEATNIK/Filter-NumberLines-0.02.tar.gz
Module = DateTime::TimeZone::Europe::Berlin (DROLSKY/DateTime-TimeZone-0.7904.tar.gz)
Module Filter::NumberLines (BEATNIK/Filter-NumberLines-0.02.tar.gz)
Author [...]
2.3. Each Package by Hand
There is a standard way to install Perl modules. Most of the time the following set of commands will integrate new modules to your systems. Virtually all Linux system should be able to perform these steps without the need to install further software packages (e.g. tools like make, gcc, awk...)
# unpack the archive
$ tar xzf your-module.tgz
# build the source codes and configure the
# process to integrate the module to teh system
$ perl Makefile.PL
$ make
$ make test
# ...or specify the location of the module
# to be installed
$ perl Makefile.PL PREFIX=/my/perl_directory
$ make
$ make test
# install the module
$ make install
Related resources:




