You'll probably have to become a privileged user with adequate
permissions to install the module in the system directories. Standard
modules are installed in a directory like
/usr/lib/perl5, whereas third-party modules are
installed in /usr/lib/perl5/site_ perl.
Here's a sample run, showing the installation of the MD5 module:
% gunzip MD5-1.7.tar.gz
% tar xf MD5-1.7.tar
% cd MD5-1.7
% perl Makefile.PL
Checking if your kit is complete...
Looks good
Writing Makefile for MD5
% 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
% 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
% sudo make install
Password:
Installing /usr/local/lib/perl5/site_perl/i386-freebsd/./auto/MD5/
MD5.so
Installing /usr/local/lib/perl5/site_perl/i386-freebsd/./auto/MD5/
MD5.bs
Installing /usr/local/lib/perl5/site_perl/./auto/MD5/autosplit.ix
Installing /usr/local/lib/perl5/site_perl/./MD5.pm
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
If your system manager isn't around or can't be prevailed upon to run
the installation, don't worry. When you use Perl to generate the
Makefile from template Makefile.PL, you can
specify alternate installation directories.
# if you just want the modules installed in your own directory
% perl Makefile.PL LIB=~/lib
# if you have your own complete distribution
% perl Makefile.PL PREFIX=~/perl5-private
An even simpler approach is to use the CPAN module from the command
line, because it can search for, download, and install the module you
need. Suppose you wanted to find the CPAN module Getopt::Declare. All
you'd have to do is type:
% perl -MCPAN -e "install Getopt::Declare"
The first time you use the CPAN module, it will ask you some
configuration questions. It saves these away so that when you use it
in the future, it won't need to ask you those questions again.
The CPAN module also supports an interactive command shell. This can
be used to search for modules whose precise names you're uncertain
of, check which CPAN modules have newer versions than you have
installed, install bundles of related modules, and various other
useful commands.
Here's an example run of the interactive shell.
% perl -MCPAN -e shell
cpan shell -- CPAN exploration and modules installation (v1.70)
ReadLine support enabled
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
cpan> i /inflect/
CPAN: Storable loaded ok
Going to read /home/tchrist/.cpan/Metadata
Database was generated on Mon, 07 Apr 2003 22:42:33 GMT
Distribution D/DC/DCONWAY/Lingua-EN-Inflect-1.88.tar.gz
Module Lingua::EN::Inflect (D/DC/DCONWAY/Lingua-EN-Inflect-1.88.tar.gz)
2 items found
cpan> install Lingua::EN::Inflect
[build and install output deleted]
cpan> quit