Read an Excerpt
Chapter 2: Installing Perl The CPAN ArchitectureCPAN represents the development interests of a cross-section of the Perl community. It contains Perl utilities, modules, documentation, and (of course) the Perl distribution itself CPAN was created by Jarkko Hietaniemi and Andreas Ming.
The home system for CPAN is funet.fi, but CPAN is also mirrored on many other sites around the globe. This ensures that anyone with an Internet connection can have reliable access to CPAN's contents at any time. Since the structure of all CPAN sites is the same, a user searching for the current version of, Perl. can be sure that the latest.tar.gz file is the same on every site.
The easiest way to access CPAN is to utilize the CPAN multiplex service at www.perl.com. The multiplexor tries to connect you to a local, fast machine on a large bandwidth hub. To use the multiplexor, go to http://www.perl.com/CPAN the multiplexor will, automatically route you to a site based on your domain.
If you prefer, you can choose a particular CPAN site, instead of letting the multiplexor choose one for you. To do that, go to the URL http://www.perl.com/CPAN (no wailing slash). When you omit the trailing slash, the CPAN multiplexor presents a menu of CPAN mirrors from which you select the one you want. It remembers your choice next time.
To get the current Perl distribution, click on latest.tar.gz. For ports to other systems, click on ports. The modules link is the one, you want if you're looking for a Perl module- from there you can get a full list of the modules, or you can access the modules directly by author, by CPAN category, or by module. (The section "Getting and Installing Modules" later in this chapter talks about installing modules. Click on doc for Perl documentation, FAQs, etc.
Installing PerlMost likely your system administrator is responsible for installing and upgrading Perl. But if you are the system administrator, or you want to install Perl on your own system, sooner or later you will find yourself. installing a new version of Perl.
If you have been running Perl, and you are now going to install Perl 5.005, you need to be aware that it 'is not binary compatible with older versions. This means that you must rebuild and reinstall any dynamically loaded extensions that you built under earlier versions.
Specific installation instructions come in the README and 17VSTALL files of the Perl distribution kit. If. you don't already have the Perl distribution, you can download it from CPAN-the latest Unix distribution is in latest.tar.gz. The information in this section is an overview of the installation process. The gory details are in the INSTALL file, which you should look at before starting, especially if you haven't done an installation before. Note that operating systems other than Unix may have special instructions; if so, follow those instructions instead of what's in this section or in INSTALL Look for a file named READMExxx, where xxx is your OS name.
In addition to Perl itself, the standard distribution includes a set of core modules that are automatically installed with Perl. See the "Getting and Installing Modules" section later in this chapter for how to install modules that are not bundled with Perl; Chapter 8, Standard Modules, describes the standard modules in, some detail.
Installing on UnixTypically, you'll get the Perl kit packed as either a tar file or as a set of shar (shell archive) scripts; in either case, the file will be in a compressed format. if you got your version of Perl directly from CPAN, it is probably in "tar-gzipped," format; tar and gzip are popular Unix data-archiving formats. In any case, once you've downloaded the distribution, you need to uncompress and unpack it. The filename indicates what kind of compression was used. A Z extension indicates you need to uncompress the file first, while a gz extension indicates you need to gunzip the file. You then unpack the file as appropriate, read the README and INSTALL files, and run a massive shell script called Configure, which tries to figure out everything about your system and creates the file Config.pm to store the information. After this is done, you do a series of "makes" to find header file dependencies, to compile Perl (and a2p, which translates awk scripts to Perl), to run regression tests, and to install Perl in your system directories.
One common problem is not making sure that Perl is linked against all the libraries it needs to build correctly. Also, you should say "yes" when Configure asks if you want dynamic loading, if your system supports it. Otherwise, you won't be able to install modules that use XS, which provides an interface between Perl and C.
If you are running Linux, some Linux distributions might not include a complete MakeMaker, which you need for installing modules. To be safe, you should make sure everything is there; one Way to do that is to check the Config.pm file. If MakeMaker is not correctly installed, you might need to build Perl yourself.
It's possible you'll get a compiled (binary) copy of Perl, rather than the source. in that case, make sure you get suidperl, a2p, s2p, and the Perl library routines. Install these files in the directories that your version was compiled for. Note that binary distributions of Perl are made available because they're handy, not because you are restricted from getting the source and compiling it yourself. The people who give you the binary distribution ought to provide you with some form of access to the source, if only a pointer to where they got the source. See the Copying file in the distribution for more information.
Perl examplesThe Perl source distribution comes with some sample scripts in the eg/ subdirectory. Feel free to browse among them and use them. They are not installed automatically, however, so you need to copy them to the appropriate directory and possibly fix the #1 line to point to the right interpreter.
The files in the. t/ and lib/ subdirectories, although arcane in spots, can also serve as examples.
PatchesSince Perl is constantly being honed and improved, patches are sometimes made available through CPAN. Your distribution is likely to have had most of the patches applied already-run perl -v to check the patch level of your distribution. Patches are sent out with complete instructions on how to apply them using patch, which is available from the GNU project.
Installing on Win32You need to obtain and install a copy of Perl yourself, unless you have had the good fortune of having a system administrator install Perl on your system.
For Perl 5.004, there are two different distributions for Win32 systems. The first is Perl for Win32, which was developed by ActiveState Tool Corporation. The second is actually the standard Perl distribution-Perl 5.004 added support for Win32 systems to the standard Perl distribution. In Perl 5.004, the two versions are largely compatible, with some of the Perl 5.004, code being based on the ActiveState port. However, there are also some differences: using either the ISAPI version of Perl or PerlScript with 5.004 requires the ActiveState distribution. On the other hand, the Win32 ports of mod_perl or Perl/Tk require the "native" (or standard) version of 5.004.
With Perl 5.005, this scenario has changed, and the two versions have been merged. if you look on CPAN, you'll see that there still seem to be two versions the ActiveState distribution, now known as ActivePerl, an& the standard distribution. The difference is that they are now based on the same source code. Get ActivePerl if you want to install from a binary distribution or get the standard distribution to build Perl from the source code.
ActivePerlThe canonical source for the ActivePerl distribution at the time of this writing is at http://www.activestate.com. Included in the distribution are:
- Perl for Win32
- Binary for the core Perl distribution
- Perl for ISAPI
- IIS plug-in for use with ISAPI-compliant web servers
- ActiveX scripting engine
- Perl Package Manager