0% found this document useful (0 votes)
51 views7 pages

Perl - 18 - Installing and Using Perl Modules

The document discusses how to unpack, build, test and install Perl modules from source. It describes unpacking module source, running MakeFile.PL, make, make test and make install. It also covers using cpan and viewing module documentation.

Uploaded by

Nitish Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
51 views7 pages

Perl - 18 - Installing and Using Perl Modules

The document discusses how to unpack, build, test and install Perl modules from source. It describes unpacking module source, running MakeFile.PL, make, make test and make install. It also covers using cpan and viewing module documentation.

Uploaded by

Nitish Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Using Modules

Contents
 CPAN

 Using Modules
 Installing a Perl Module
 Unpacking the Module Source
 The Configuration Step
 The Build Step
 The Test Step
 The Install Step
 Using CPAN.pm
 Using Module Documentation

1
Objectives
 In this session we will learn how to

 Unpack module source.

 Build, Test and Install the module.

 Specify alternate directories for installing a module.

 View module documentation.

Building a CPAN Module


 Perlmodules are available in source kits stored as tar
archives in GNU zip format.

 NOTE: If tar warns of "Directory checksum errors",


then you downloaded the binary file in text format.

 Standard modules are installed in the following directory


 /usr/lib/perl5

 Third-party modules are installed in the following


directory
 /usr/lib/perl5/site_ perl

2
Unpacking Module Source
 Tounpack the module source use the gunzip and tar
commands.

 Forexample to unpack the 4.54 of the Some::Module


package, type the commands as follows:

 gunzip Some-Module-4.54.tar.gz
 tar xf Some-Module-4.54

 Themodule source will be unpacked into a folder. In our


example case Some-Module-4.54 directory.

To Build, Test & Install


 Once the module source is unpacked, we can build, test
and install the module as follows:
 perl MakeFile.PL
 make
 make test
 make install

 NOTE : You need to be a privileged user with adequate


permissions to install the module in the system
directories.

3
Build, Test & Install - Sample
A sample run showing the installation of MD5 module:
$
$ # Change over to the unpacked module source
$ cd MD5-1.7
$
$ # Build Step-1
$ perl Makefile.PL
Checking if your kit is complete...
Looks good
Writing Makefile for MD5

Build, Test & Install - Sample


A sample run showing the installation of MD5 module:
$ # Build Step-2
$ make
mkdir ./blib
mkdir ./blib/lib
cp MD5.pm ./blib/lib/MD5.pm
AutoSplitting MD5 (./blib/lib/auto/MD5)
/usr/bin/perl -I/usr/local/lib/perl5/i386 ...
...
cp MD5.bs ./blib/arch/auto/MD5/MD5.bs
chmod 644 ./blib/arch/auto/MD5/MD5.bsmkdir
./blib/man3
Manifying ./blib/man3/MD5.3

4
Build, Test & Install - Sample
A sample run showing the installation of MD5 module:
$ # Test Step
$ make test
PERL_DL_NONLAZY=1 /usr/bin/perl -I./blib/arch
-I./blib/lib
-I/usr/local/lib/perl5/i386-freebsd/5.00404 -
I/usr/local/lib/perl5 test.pl
1..14
ok 1
ok 2
...
ok 13
ok 14

Build, Test & Install - Sample


$ # Test Step
$ sudo make install
Password:
Installing
/usr/local/lib/perl5/site_perl/i386-
freebsd/./auto/MD5/
MD5.so
Installing
:
/usr/local/lib/perl5/man/man3/./MD5.3
Writing /usr/local/lib/perl5/site_perl/i386-
freebsd/auto/MD5/.packlist
Appending installation info to
/usr/local/lib/perl5/i386-freebsd/
5.00404/perllocal.pod

5
Alternate Installation Directory
 You can specify alternate installation directory while
building the module.
 perl MakeFile.PL LIB=~/mylib

 Recall
: You know how to access the modules available
any where in the file system.

Use ‘cpan’ Utility


 Modules can also be installed using ‘cpan’ utility.
 Advantage : Resolves dependencies.
$
$ # Invoke the ‘cpan’ utility
$ cpan
$
cpan>

 Check the help for cpan utility. Just type h

6
Using Module Documentation
 Look into the module documentation for more
information on a specific module.
 Use the perldoc utility to view module documentation

$
$ perldoc DBI
$

You might also like