We suggest limiting your customization of the Perl that came with Mac OS X, since it's fair game for modification during an upgrade or patch. You could either end up modifying something that the system depends on, or you could end up with a partially broken Perl installation the next time Software Update performs a big Mac OS X update.
It's fine to install whatever Perl modules you want, but if you choose to install a customized or newer version of Perl, install it in /usr/local so it doesn't interfere with the one in /usr . You should use /usr/bin/cpan (a shell interface to the CPAN.pm module) to install modules, but don't stray too far from your desk when you're doing this ”you might come back to find that your module selection led to a dependency that tried to do you a favor by upgrading Perl to the latest version.
The first time you use the CPAN shell, it asks many questions about how you'd like to set it up (you can enter the initial CPAN configuration any time by issuing the command o conf init within the CPAN shell):
$ sudo cpan Password: ******** /System/Library/Perl/5.8.1/CPAN/Config.pm initialized. CPAN is the world-wide archive of perl resources. It consists of about 100 sites that all replicate the same contents all around the globe. Many countries have at least one CPAN site already. The resources found on CPAN are easily accessible with the CPAN.pm module. If you want to use CPAN.pm, you have to configure it properly. If you do not want to enter a dialog now, you can answer 'no' to this question and I'll try to autoconfigure. (Note: you can revisit this dialog anytime later by typing 'o conf init' at the cpan prompt.) Are you ready for manual configuration? [yes]
From here on in, all of the default options are safe. When it comes time to select your preferred CPAN mirrors, follow the prompts and choose your geographic location. When you're finished, CPAN lists the mirrors you've selected and prompts you for your next action:
New set of picks: ftp://archive.progeny.com/CPAN/ ftp://carroll.cac.psu.edu/pub/CPAN/ ftp://cpan-du.viaverio.com/pub/CPAN/ ftp://cpan-sj.viaverio.com/pub/CPAN/ ftp://cpan.calvin.edu/pub/CPAN commit: wrote /System/Library/Perl/5.8.1/CPAN/Config.pm Terminal does not support AddHistory. cpan shell -- CPAN exploration and modules installation (v1.76) ReadLine support available (try 'install Bundle::CPAN') cpan>
The string cpan> is the CPAN module's shell prompt. Your first order of business should be to run the command install Bundle::CPAN . This installs a bunch of modules that make your CPAN experience a bit nicer, including modules that support command-line history with the up and down arrows and command-line editing. Before doing this, Jaguar users should refer to the following section; Panther and Jaguar users should see Section 10.2.2, later in this chapter, for notes on some potential problems installing this bundle.
10.2.1 Jaguar and CPAN
Jaguar users should immediately upgrade to the latest version of the CPAN module, since the version of the module that shipped with Jaguar will try to upgrade all of Perl under many circumstances. This could make things very messy. The most recent versions of the CPAN module, including the one that ships with Panther, don't have this problem.
Jaguar users should not use the CPAN shell for the initial upgrade of the CPAN module. Instead, follow these steps:
If you see that CPAN has decided to install Perl, press Control-C a couple of times; it usually recovers just fine. Here's what it looked like on Jaguar when we tried to issue the command install Bundle::CPAN on a fresh install of Jaguar:
Running make for N/NW/NWCLARK/perl-5.8.2.tar.gz Issuing "/usr/bin/ftp -n" Connected to archive.progeny.com. 220 archive.progeny.com FTP server ready. [... output abbreviated ...] local: perl-5.8.2.tar.gz remote: perl-5.8.2.tar.gz 229 Entering Extended Passive Mode (50600) 150 Opening BINARY mode data connection for 'perl-5.8.2.tar.gz' (11896287 bytes). 15% ******* 1767 KB 196.36 KB/s ^C
10.2.2 CPAN and Dependency Problems
You may run into dependency problems with some of the CPAN modules; and sometimes the answers to these problems won't be immediately obvious. For example, after setting up a fresh install of Panther, we ran cpan for the first time. After going through the initial configuration, we installed Bundle::CPAN. Although it installed most of the required modules, it complained on libnet (Perl modules for network programming):
CPAN is up to date. Bundle summary: The following items in bundle Bundle::CPAN had Installation problems: Bundle::libnet and the following items had problems during recursive bundle calls: Data::Dumper CPAN: Term::ReadLine::Perl loaded ok .................... 20 subroutines in Term::ReadLine redefined cpan shell -- CPAN exploration and modules installation (v1.76) ReadLine support enabled cpan>
So we scrolled back to see what had happened with Data::Dumper. Oddly enough, everything looked fine:
Running make install Installing /Library/Perl/5.8.1/ darwin-thread-multi-2level/auto/Data/Dumper/Dumper.bs Installing /Library/Perl/5.8.1/ darwin-thread-multi-2level/auto/Data/Dumper/Dumper.bundle Files found in blib/arch: installing files in blib/lib into architecture dependent library tree Installing /Library/Perl/5.8.1/darwin-thread-multi-2level/Data/Dumper.pm Writing ///Library/Perl/5.8.1/ darwin-thread-multi-2level/auto/Data/Dumper/.packlist Appending installation info to ///System/Library/Perl/ 5.8.1/darwin-thread-multi-2level/perllocal.pod /usr/bin/make install -- OK
Just to be sure we had only the latest Data::Dumper on our Mac, we configured cpan to uninstall existing versions of modules (by setting make_install_arg as shown in the following listing), and for extra measure, force-installed Data::Dumper, and finally reset make_install_arg back to its original setting:
cpan> o conf make_install_arg UNINST=1 make_install_arg UNINST=1 cpan> force install Data::Dumper Running install for module Data::Dumper Running make for I/IL/ILYAM/Data-Dumper-2.121.tar.gz [... output abbreviated ...] Appending installation info to ///System/Library/Perl/5.8.1/darwin-thread- multi-2level/perllocal.pod /usr/bin/make install UNINST=1 -- OK cpan> o conf make_install_arg "" make_install_arg
Next, we exited cpan with quit, and ran it again. Just to make sure it didn't get hung up about some of the failed installs that had gone before, we tried to install the Bundle::CPAN again. This time, it completed successfully:
$ sudo cpan cpan shell -- CPAN exploration and modules installation (v1.76) ReadLine support enabled cpan> install Bundle::CPAN CPAN: Storable loaded ok Going to read /Users/bjepson/.cpan/Metadata Database was generated on Tue, 25 Nov 2003 08:46:32 GMT File::Spec is up to date. Digest::MD5 is up to date. Compress::Zlib is up to date. Archive::Tar is up to date. Data::Dumper is up to date. Net::Telnet is up to date. Running install for module Net::Cmd Running make for G/GB/GBARR/libnet-1.17.tar.gz [... output abbreviated ...] Appending installation info to ///System/Library/Perl/5.8.1/darwin-thread-multi-2level/perllocal.pod /usr/bin/make install -- OK Term::ReadKey is up to date. Term::ReadLine::Perl is up to date. CPAN is up to date.