The main distribution point for Perl is the Comprehensive Perl Archive Network, or CPAN. This archive contains not only the source code, but also just about everything you could ever want that's Perl-related. CPAN is mirrored by dozens of sites all over the world, as well as a few down under. The main site is ftp.funet.fi (184.108.40.206). You can find a more local CPAN site by getting the file /pub/languages/perl/CPAN/MIRRORS from ftp.funet.fi. Or you can use your web browser to access the CPAN multiplex service at www.perl.com. Whenever you ask this web server for a file starting with /CPAN/, it connects you to a CPAN site, which it chooses by looking at your domain name. Here are some popular universal resource locators (URLs) out of CPAN:
The CPAN multiplex service tries to connect you to a local, fast machine on a large bandwidth hub. This doesn't always work, however, because domain names may not reflect network connections. For example, you might have a hostname ending in .se, but you may actually be better connected to North America than to Sweden. If so, you can use the following URL to choose your own site:
Note the absence of a slash at the end of the URL. When you omit the trailing slash, the CPAN multiplexer presents a menu of CPAN mirrors from which you can select a site. So long as your web browser supports cookies, the CPAN multiplexer will automatically remember your choice next time.
The following machines should have the Perl source code plus a copy of the CPAN mirror list - both available via anonymous FTP. (Try to use the machine names rather than the numbers, since the numbers may change.)
The location of the top directory of the CPAN mirror differs on these machines, so look around once you get there. It's often something like /pub/perl/CPAN.
Under the main CPAN directory, you'll see at least the following subdirectories:
This directory contains numerous subdirectories, one for each contributor of software. For example, if you wanted to find Lincoln Stein's great CGI.pm module, and you knew for a fact that he wrote it, you could look in authors/Lincoln_Stein. If you didn't know he wrote it, you could look in the modules directory explained below.
A directory containing all manner of Perl documentation. This includes all official documentation (manpages) in several formats (such as ASCII text, HTML, PostScript, and Perl's native POD format), plus the FAQs and interesting supplementary documents.
This directory contains unbundled modules written in C, Perl, or both. Extensions allow you to emulate or access the functionality of other software, such as Tk graphical facilities, the UNIX curses library, and math libraries. They also give you a way to interact with databases (Oracle, Sybase, etc.), and to manage HTML files and CGI scripts.
This directory contains the source code and/or binaries for Perl ports to operating systems not directly supported in the standard distribution. These ports are the individual efforts of their respective authors, and may not all function precisely as described in this book.
A collection of diverse scripts from all over the world. If you need to find out how to do something, or if you just want to see how other people write programs, check this out. The subdirectory nutshell contains the examples from this book. (You can also find these sources at the O'Reilly & Associates ftp.ora.com site, in /published/oreilly/nutshell/learning_perl2/.
Within this directory you will find the source for the standard Perl distribution. The current production release is always in the file that is called src/latest.tar.gz. This large file contains full source and documentation for Perl. Configuration and installation should be relatively straightforward on UNIX and UNIX-like systems, as well as VMS and OS/2. Starting with Version 5.004, Perl also builds on 32-bit Windows systems.
 The trailing .tar.gz means that it's in the standard Internet format of a GNU-zipped, tar archive.
In the event you've never used anonymous FTP, here is a quick primer in the form of a sample session with comments. Text in bold typewriter font is what you should type; comments are in italics. The % represents your prompt, and should not be typed.
% ftp ftp.CPAN.org (ftp.CPAN.org is not a real site) Connected to ftp.CPAN.org. 220 CPAN FTP server (Version wu-2.4(1) Fri Dec 1 00:00:00 EST 1995) ready. Name (ftp.CPAN.org:CPAN): anonymous 331 Guest login ok, send your complete e-mail address as password. Password: email@example.com (Use your username and host here) 230 Guest login ok, access restrictions apply. ftp> cd pub/perl/CPAN/src 250 CWD command successful. ftp> binary (You must specify binary transfer for compressed files) 200 Type set to I. ftp> get latest.tar.gz 200 PORT command successful. 150 Opening BINARY mode data connection for FILE. 226 Transfer complete. . . (repeat this step for each file you want) . ftp> quit 221 Goodbye. %
Once you have the files, first unzip and untar them, and then configure, build, and install Perl:
% gunzip < latest.tar.gz | tar xvf - % cd perl5.003 (Use actual directory name) Now either one of these next two lines: % sh configure (Lowercase "c" for automatic configuration) % sh Configure (Capital "C" for manual configuration) % make (Build all of Perl) % make test (Make sure it works) % make install (You should be the superuser for this)
For retrieving and building unbundled Perl modules, the process is slightly different. Let's say you want to build and install a module named CoolMod. You'd first fetch it via ftp (1), or you could use your web browser to access the module service from http://www.perl.com/, which always retrieves the most up-to-date version of a particular registered module. The address to feed your browser would be similar to:
Once you've gotten the file, do this:
% gunzip < CoolMod-2.34.tar.gz | tar xvf - % cd CoolMod-2.34 % perl Makefile.PL (Creates the real Makefile) % make (Build the whole module) % make test (Make sure it works) % make install (Probably should be the superuser)
When the CoolMod module has been successfully installed (it is automatically placed in your system's Perl library path), your programs can say:
and you should be able to run man CoolMod (or maybe perldoc CoolMod ) to read the module's documentation.