9.3. Building a Perl Module
Building a Perl module and installing it is simple and usually
painless. Perl modules are distributed as
gzipped tar archives. You
can unpack them like this:
panic% gunzip -c CPAN-1.60.tar.gz | tar xvf -
CPAN-1.60/
CPAN-1.60/lib/
CPAN-1.60/lib/CPAN/
CPAN-1.60/lib/CPAN/Nox.pm
CPAN-1.60/lib/CPAN/Admin.pm
CPAN-1.60/lib/CPAN/FirstTime.pm
CPAN-1.60/lib/Bundle/
CPAN-1.60/lib/Bundle/CPAN.pm
CPAN-1.60/lib/CPAN.pm
CPAN-1.60/Todo
CPAN-1.60/ChangeLog
CPAN-1.60/t/
CPAN-1.60/t/loadme.t
CPAN-1.60/t/vcmp.t
CPAN-1.60/MANIFEST
CPAN-1.60/Makefile.PL
CPAN-1.60/cpan
CPAN-1.60/README
Or, if you are using a GNU tar utility, you can
unpack the package in one command:
panic% tar zxvf CPAN-1.59.tzr.gz
Once the archive has been unpacked, you'll have to
enter the newly created directory and issue the perl
Makefile.PL, make, make
test, and make install commands.
Together, these will build, test, and install the module:
panic% cd CPAN-1.60
panic% perl Makefile.PL
Checking if your kit is complete...
Looks good
Writing Makefile for CPAN
panic% make
cp lib/CPAN/Nox.pm blib/lib/CPAN/Nox.pm
cp lib/Bundle/CPAN.pm blib/lib/Bundle/CPAN.pm
cp lib/CPAN/Admin.pm blib/lib/CPAN/Admin.pm
cp lib/CPAN.pm blib/lib/CPAN.pm
cp lib/CPAN/FirstTime.pm blib/lib/CPAN/FirstTime.pm
cp cpan blib/script/cpan
/usr/bin/perl -I/usr/lib/perl5/5.6.1/i386-linux
-I/usr/lib/perl5/5.6.1 -MExtUtils::MakeMaker
-e "MY->fixin(shift)" blib/script/cpan
Manifying blib/man3/CPAN::Nox.3
Manifying blib/man3/Bundle::CPAN.3
Manifying blib/man3/CPAN::Admin.3
Manifying blib/man3/CPAN.3
Manifying blib/man3/CPAN::FirstTime.3
panic% make test
PERL_DL_NONLAZY=1 /usr/bin/perl -Iblib/arch -Iblib/lib
-I/usr/lib/perl5/5.6.1/i386-linux -I/usr/lib/perl5/5.6.1
-e 'use Test::Harness qw(&runtests $verbose);
$verbose=0; runtests @ARGV;'
t/*.t
t/loadme............ok
t/vcmp..............ok
All tests successful.
Files=2, Tests=31, 3 wallclock secs ( 1.22 cusr + 0.91 csys = 2.13 CPU)
Become root if you need to install the module on
the whole system:
panic% su
<root password>
panic# make install
Installing /usr/lib/perl5/man/man3/CPAN::Nox.3
Installing /usr/lib/perl5/man/man3/Bundle::CPAN.3
Installing /usr/lib/perl5/man/man3/CPAN::Admin.3
Installing /usr/lib/perl5/man/man3/CPAN.3
Installing /usr/lib/perl5/man/man3/CPAN::FirstTime.3
Writing /usr/lib/perl5/5.6.1/i386-linux/auto/CPAN/.packlist
Appending installation info to /usr/lib/perl5/5.6.1/i386-linux/perllocal.pod