PERL MODULES


It is often the case with code, that a subroutine or function may need to be reused by a number of programs. In this situation, it would be easier to write the subroutine once and then call it from each program. A Perl module provides this capability.

A Perl module is a package stored in a single file. The Perl module has the same name as the package, but is given the extension .pm to denote a perl module.

Exporting Perl Module Symbols

A Perl module allows symbols such as a subroutine name or a variable name to be exported to the program that it is called by. The symbols are exported by means of the Perl Exporter module. Typically, the @ISA array is used too to check for the import method.

Installing a Perl Module.

  1. Determine which type of Perl module you require
  2. Go to www.cpan.org (The Comprehensive Perl Archive Network)
  3. Identify the relevant module and download the module
The Perl module will most likely be stored in a compressed tar format (tar.gz), so the module will need to be decompressed as follows:

>gunzip Perlmodulename.tar.gz
>tar -xvf Perlmodulename.tar

Now the module is installed as follows:

>perl Makefile.PL

>make
>make test

>make install

Useful Perl Modules



www.cyberthinc.com