1.5. Locating and Installing ModulesMuch of the benefit of using Perl for system administration work comes from all of the free code available in module form. The modules mentioned in this book can be found in one of three places:
How do you install one of these modules when you find it? The answer depends on the operating system you are running. Perl now ships with documentation on this process in a file called perlmodinstall.pod (type perldoc perlmodinstall to read it). The next sections provide brief summaries of the steps required for each operating system used in this book. 1.5.1. Installing Modules on UnixIn most cases, the process goes like this:
If you want to save yourself the trouble of performing these steps all by hand, you can use the CPAN module by Andreas J. König (shipped with Perl). This module allows you to perform all of those steps by typing: % perl -MCPAN -e shell cpan> install modulename The CPAN module is smart enough to handle module dependencies (i.e., if one module requires another module to run, it will install both modules for you automatically). CPAN also has a built-in search function for finding related modules and packages. I recommend typing perldoc CPAN on your system to see all of the handy features of this module. 1.5.2. Installing Modules on Win32The process for installing modules on Win32 platforms mirrors that for Unix with one additional step, ppm. If you plan to install modules by hand using the Unix instructions above, you can use programs like WinZip (http://www.winzip.com) to unpack a distribution and nmake (found at ftp://ftp.microsoft.com/Softlib/MSLFILES/nmake15.exe) instead of make to build and install a module. Some modules require compilation of C files as part of their build process. A large portion of the Perl users in the Win32 world do not have the necessary software installed on their computers for this compilation, so ActiveState created the Perl Package Manager to handle pre-built module distribution. The PPM system is similar to that of the CPAN module. It uses a Perl program called ppm.pl to handle the download and installation of special archive files from PPM repositories. You can either start this program by typing ppm or by running perl ppm.pl from within the Perl bin directory: C:\Perl\bin>perl ppm.pl PPM interactive shell (1.1.1) - type 'help' for available commands. PPM> install module-name ppm, like CPAN, can also search the list of available and installed modules for you. Type help at the ppm command prompt for more information on how to use these commands. 1.5.3. Installing Modules on MacOSInstalling modules on MacOS is a strange hybrid of the methods we've seen so far. Chris Nandor has put together a distribution called cpan-mac (found either at CPAN or http://pudge.net/macperl) that includes ports of CPAN and a whole slew of other important modules to the Mac. Once the cpan-mac distribution is installed, it is possible to download most Perl-only modules from CPAN and install them. Nandor makes this task easy by providing an MacPerl droplet called installme. Archive files (i.e., .tar.gz files) dropped on top of installme will be de-archived and installed in a CPAN-like fashion. For more information on MacOS module installation, be sure to see an expanded version of the perlmodinstall.pod document mentioned earlier called macperl modinstall.pod. This can also be found at http://pudge.net/macperl. Copyright © 2001 O'Reilly & Associates. All rights reserved. |
|