Perl Modules

Introduction to Perl Modules

The Perl module packages add useful objects to the Perl language. Modules utilized by packages throughout BLFS are listed here, along with their dependencies. Most references to Perl modules are in the form of Module, Module::SubName or Module::Sub::Name, however occasionally you'll also see Module, Module-SubName or Module-Sub-Name. Most references on this page are in the latter form, as these are the official package names.

The Module::Info Module

One module in particular is shown first, as this module's usefulness warrants installation, even though it won't be required by many other modules. The Module::Info module can tell you if a particular module is included in, or has been installed into your Perl installation. Additionally, Module::Info can tell you what versions are installed and what dependencies are required for them. You can even use Module::Info to gather dependencies of uninstalled modules.

The Test::Pod Module

Another useful module, and one which is (typically optionally) used by other modules during the build process is the Test:Pod module. This module is used to check the validity of POD (Plain Old Documentation) files. The Test::Pod module is typically included by module authors to automatically find and check all POD files in a module distribution. This module and all the dependencies can be installed using the build and installation instructions.

The Module::Build Module

The Module::Build module is a system for building, testing, and installing Perl modules. It is meant to be an alternative to ExtUtils::MakeMaker. Developers may alter the behavior of the module through subclassing in a much more straightforward way than with MakeMaker. It also does not require a make command on your system. Most of the Module::Build code is pure-Perl and written in a very cross-platform way.

The Module::Build module (as well as any other Perl module that uses the Module::Build build system) uses modified build instructions. All the dependencies can be installed using the build and installation instructions.

[Note]

Note

The Compress::Zlib module requires the following sed after untarring the distribution tarball (before any other build commands) to use the system-installed copy of Zlib.

sed -i -e "s|BUILD_ZLIB = True|BUILD_ZLIB = False|" \
       -e "s|INCLUDE    = ./zlib-src|INCLUDE    = /usr/include|" \
       -e "s|LIB        = ./zlib-src|LIB        = /usr/lib|" \
    config.in

Module::Build Build and Installation Instructions

perl Build.PL &&
./Build test

Now, as the root user:

./Build install

The HTML::Parser Module

The HTML::Parser distribution is a collection of modules that parse and extract information from HTML documents. In order to use the included HTML::HeadParser module, you will also need to install LWP. The two modules listed below can be installed using the Perl Module build and installation instructions.

The XML::Parser Module

The XML::Parser module is a Perl extension interface to James Clark's XML parser, expat. The module can be installed using the Perl Module build and installation instructions.

The SGMLSpm Module

The SGMLSpm module is a Perl library used for parsing the output from James Clark's SGMLS and NSGMLS parsers. This module requires modified installation instructions, shown below.

If your system's Perl version is different than 5.8.6, you'll need to modify the sed command below to reflect the version you have installed.

sed -i -e "s@/usr/local/bin@/usr/bin@" \
       -e "s@/usr/local/lib/perl5@/usr/lib/perl5/site_perl/5.8.6@" \
       -e "s@/usr/local/lib/www/docs@/usr/share/doc/perl5@" \
    Makefile

Now, as the root user:

make install &&
install -v -d -m755 /usr/share/doc/perl5 &&
make install_html &&
rm -v -f /usr/share/doc/perl5/SGMLSpm/sample.pl &&
install -v -m644 DOC/sample.pl /usr/share/doc/perl5/SGMLSpm

The Tk Module

The Tk module is a Perl interface to the Tk package. The goal of this release is Unicode support via Perl's and core-Tk's use of UTF-8. Tk-804.027 builds and loads into a threaded Perl but is NOT yet thread safe. The module can be installed using the Perl Module build and installation instructions.

The Net::DNS Module

Net::DNS is a DNS resolver implemented in Perl. It can be used to perform nearly any type of DNS query from a Perl script. The Net::DNS module and all its dependencies can be installed using the Perl Module build and installation instructions.

The LWP Module

The libwww-perl (LWP) collection is a set of Perl modules which provides a simple and consistent application programming interface to the World-Wide Web. The main focus of the library is to provide classes and functions that allow you to write WWW clients. The library also contains modules that are of more general use and even classes that help you implement simple HTTP servers. The LWP modules and all its Perl module dependencies can be installed using the Perl Module build and installation instructions.

[Note]

Note

The Compress::Zlib module requires the following sed after untarring the distribution tarball (before any other build commands) to use the system-installed copy of Zlib.

sed -i -e "s|BUILD_ZLIB = True|BUILD_ZLIB = False|" \
       -e "s|INCLUDE    = ./zlib-src|INCLUDE    = /usr/include|" \
       -e "s|LIB        = ./zlib-src|LIB        = /usr/lib|" \
    config.in

The Date::Manip Module

Date::Manip is a set of routines designed to make any common date/time manipulation easy to do. Operations such as comparing two times, calculating a time a given amount of time from another, or parsing international times are all easily done. From the very beginning, the main focus of Date::Manip has been to be able to do ANY desired date/time operation easily.

The Finance::Quote Module

Finance::Quote is used to get stock quotes from various Internet sources, including Yahoo! Finance, Fidelity Investments, and the Australian Stock Exchange. There are two methods of using this module – a functional interface that is depreciated, and an object-orientated method that provides greater flexibility and stability. With the exception of straight currency exchange rates, all information is returned as a two-dimensional hash (or a reference to such a hash, if called in a scalar context).

After you've installed the package, issue perldoc Finance::Quote for full information. Alternatively, you can issue perldoc lib/Finance/Quote.pm after unpacking the distribution tarball and changing into the top-level directory. The module and dependencies can be installed using the Perl module build and installation instructions.

[Note]

Note

To run the regression test suite, you'll need to create a symbolic link to the test directory using the following command after unpacking the tarball and changing into the root directory of the sources:

ln -s test t

Some tests will fail depending on certain conditions. See the INSTALL file for full details.

The Finance::QuoteHist Module

The Finance::QuoteHist bundle is several modules designed to fetch historical stock quotes from the web. The module and dependencies can be installed using the Perl module build and installation instructions.

Standard Installation of Perl Modules

Install Perl modules by running the following commands:

perl Makefile.PL &&
make &&
make test

Now, as the root user:

make install

(Alternate) Auto Installation of Perl Modules.

There is an alternate way of installing the modules using Perl's built-in install command. The command automatically downloads the source from the CPAN archive, extracts it, runs the commands mentioned above, and removes the build tree. You may still need to install dependent library packages before running the automated installation method.

The first time you run this command, you'll be prompted to enter some information regarding download locations and methods. This information is retained in files located in ~/.cpan. Start the perl shell with the following command as the root user:

perl -MCPAN -e shell

Each module may now be installed from this shell with the command:

install [Module::Name]

For additional commands and help, type help.

Alternatively, for scripted or non-interactive installations, use the following syntax as the root user:

perl -MCPAN -e 'install [Module::Name]'

Last updated on 2005-08-01 13:29:19 -0600