Appendix A

Perl Acquisition and Installation


CONTENTS

Perl is easily and readily available on the Internet. Best of all, it's free. As mentioned in Chapter 1 "Perl Overview," Perl is protected under the GNU General Public License, which maintains copyright protection for the author but allows other people to freely use and modify the software. The only costs that you can be charged are transferring costs, warranty protection, or support; you cannot be charged for Perl itself. If the software is modified, the modification must carry notices to this effect, and the modified Perl itself must be licensed under the GNU General Public License. One method of highlighting extensive modifications is renaming Perl to fit the new functionality; this policy accounts for the versions or extensions of Perl called MacPerl or oraperl.

After you access Perl and install it, you have several sources of help on the Internet. Appendix B, "Perl Web Reference," lists several sites that have Perl-related libraries, modules, or documentation. Also included in Appendix B is a list of several Usenet groups that you can visit to find the latest information on Perl or to post a question.

In addition, a couple of books on Perl 5.0 can provide help:

History and Version Information

ON THE WEB
Perl has been around for several years. Usenets on Perl (such as comp.lang.perl.misc) existed in the late 1980s, and the defining book on Perl, Programming Perl, was published in 1991 by O'Reilly & Associates, Inc. Since that time, the numbers of users-and uses-of this language have grown considerably, aided in part by the considerable interest in applications on the Internet and by the ease with which this language can be used with CGI programming

The popularity of Perl can be attributed to several factors, the first of which is, of course, its price. Most people would much rather use a tool that works and does not cost anything than one that works and does have a cost. A second factor is that you get a considerable amount of functionality with a minimum amount of code, yet the code is not so cryptic that it's almost painful to work with, as awk can be. A third factor must be that you can get a small program up and running within minutes, without having to set up makefiles, compile the program (in the traditional sense), or perform any of the other processes that you have to follow when you work with a compiled language such as C.

A fourth factor that has to be included among the advantages of using Perl is the availability of so many libraries, modules, and sample code and scripts on the Internet. Appendix B, "Perl Web Reference," lists the URLs of many locations that have these resources. When reading through these URLs, you might wonder (as many people probably do) whether anything related to CGI programming has not already been created. The really great thing about all this is that, like Perl, the vast majority of these tools, libraries, and scripts are free. Really, this Perl-and-CGI thing sounds better all the time.

A last factor in the strength of using Perl, particularly for Web application development, is the fact that it is available for many platforms. You might have to make some modifications to the Perl script, based on the operating system that you are working on, but the basic components, concepts, and capabilities are the same, providing that the platform supports the release of Perl for which you are coding.

NOTE
My first exposure to Perl was at the request of a customer for a contract that I was working on. The customer requested that I use Perl to complete the job. I was reluctant to use a scripting language, because I had recently completed a fairly massive job by using shell scripts and "fun" tools such as awk. By the time I was done with the job, however, I was impressed with Perl, and I have become even more so with Perl 5.0. After working with CGI, I knew that I had found a perfect partnership: CGI and Perl

Perl Version 5.0

In 1993, Larry Wall, the creator of Perl, began to issue alpha releases of a new version of Perl. On October 19, 1994, Perl 5.0 was officially released. This new version of Perl was a basic rewrite of the Perl language that included new and improved features, of which the following are only a small subset:

The original version of Perl 5.0 could be compiled primarily on UNIX and VMS systems. Since that time, the original version of Perl 5.0 has been migrated to most systems. In addition, there have been two major releases of Perl 5.0: Perl 5.001 and Perl 5.002. Ports to Perl 5.002 are still occurring, but Perl 5.001 should be readily available for most operating systems.

If the original Perl can be considered to be a perfect blend of the best of C and shell scripting, Perl 5.0 can be extended to include C++. This version allows you to work with objects, which you can instantiate and use as easily as this:


use FOO;

$somevar = new FOO;

After you create an instance of the object, you can reference its methods as easily as this:


$somevar->method;

Another excellent enhancement of Perl 5.0 is its integration with OLE on Windows 95 and Windows NT. Using OLE automation techniques with Perl 5.0 is now very similar to accessing them with Visual Basic and other applications, such as PowerBuilder 5.0. With this main-streaming of the technique, a developer can transfer his or her knowledge between the tools, rather than learn a new technique to use what should be an open technology.

These features, and those listed earlier in this section and discussed on the Internet, have definitely opened intriguing new possibilities for this language.

Availability by OS

You can obtain Perl from any of the CPAN (Comprehensive Perl Archive Network) mirror sites listed in Table A.1. You also can find some of these sites through Yahoo, at http://www.yahoo.com/Computers_and_Internet/Programming_Languages/Perl/ CPAN_Comprehensive_Perl_Archive_Network/.

Table A.1  CPAN Mirror Sites

SiteURL
North America: Canadaftp://enterprise.ic.gc.ca/pub/perl/CPAN/
North America: Californiaftp://ftp.digital.com/pub/plan/perl/CPAN/
North America: Californiaftp://ftp.cdrom.com/pub/perl/CPAN/
North America: Coloradoftp://ftp.cs.colorado.edu/pub/perl/CPAN/
North America: Floridaftp://ftp.cis.ufl.edu/pub/perl/CPAN/
North America: Illinoisftp://uiarchive.cso.uiuc.edu/pub/lang/perl/CPAN/
North America: New Yorkftp://ftp.rge.com/pub/languages/perl/CPAN/
North America: Oklahomaftp://ftp.uoknor.edu/mirrors/CPAN/
North America: Texasftp://ftp.sterling.com/programming/languages/perl/
North America: Texasftp://ftp.sedl.org/pub/mirrors/CPAN/
North America: Texasftp://ftp.metronet.com/pub/perl/
Africaftp://ftp.is.co.za/programming/perl/CPAN/
Australiaftp://coombs.anu.edu.au/pub/perl/
Australiaftp://ftp.mame.mu.oz.au/pub/perl/CPAN/
New Zealandftp://ftp.tekotago.ac.nz/pub/perl/CPAN/
Europe: Austriaftp://ftp.tuwien.ac.at/pub/languages/perl/CPAN/
Europe: Belgiumftp://ftp.kulnet.kuleuven.ac.be/pub/mirror/CPAN/
Europe: Czech Republicftp://sunsite.mff.cuni.cz/Languages/Perl/CPAN/
Europe: Denmarkftp://sunsite.auc.dk/pub/languages/perl/CPAN/
Europe: Finlandftp://ftp.funet.fi/pub/languages/perl/CPAN/
Europe: Franceftp://ftp.ibp.fr/pub/perl/CPAN/
Europe: Franceftp://ftp.pasteur.fr/pub/computing/unix/perl/CPAN/
Europe: Germanyftp://ftp.leo.org/pub/comp/programming/languages/perl/CPAN/
Europe: Germanyftp://ftp.rz.ruhr-unibochum.de/pub/CPAN/
Europe: Greeceftp://ftp.ntua.gr/pub/lang/perl/
Europe: Hungaryftp://ftp.kfki.hu/pub/packages/perl/CPAN/
Europe: Italyftp://cis.utovrm.it/CPAN/
Europe: The Netherlandsftp://ftp.cs.ruu.nl/pub/PERL/CPAN/
Europe: Polandftp://ftp.pk.edu.pl/pub/lang/perl/CPAN/
Europe: Polandftp://sunsite.icm.edu.pl/pub/CPAN/
Europe: Portugalftp://ftp.ci.uminho.pt/pub/lang/perl/
Europe: Spainftp://ftp.etse.urv.es/pub/mirror/perl/
Europe: Spainftp://ftp.rediris.es/mirror/CPAN/
Europe: Swedenftp://ftp.sunet.se/pub/lang/perl/CPAN/
Europe: Switzerlandftp://ftp.switch.ch/mirror/CPAN/
Europe: United Kingdomftp://ftp.demon.co.uk/pub/mirrors/perl/CPAN/
Europe: United Kingdomftp://sunsite.doc.ic.ac.uk/packages/CPAN/
Europe: United Kingdomftp://unix.hensa.ac.uk/mirrors/perl-CPAN/
Japanftp://ftp.lab.kdd.co.jp/lang/perl/CPAN/
Taiwanftp://dongpo.math.ncu.edu.tw/perl/CPAN/
South America: Chileftp://sunsite.dcc.uchile.cl/pub/Lang/perl/CPAN/

If you access these sites by using a Web browser, you will see a listing of subdirectories and files similar to that shown in figure A.1. In addition, you can enter http://www.perl.com/CPAN/ into your browser, and you will automatically be routed to the CPAN site nearest to your location.

Figure A.1 : This figure shows a typical CPAN site in a WWW browser.

The Perl ports and their locations relative to the CPAN location are listed in the following sections. For all operating systems, the most recent version and release are given as they were known at the time when this book was written.

NOTE
For most operating systems, Perl has been ported to version 5.0, but some operating systems are still in version 4.0

UNIX

Perl was originally created for UNIX, and new releases of Perl make it to this operating system before any other. You can access the most current release by opening the URL http://www.perl.com/CPAN/src/5.0/ with your WWW browser. At this location, you are in the source directory of Perl 5.0. Access the most recent stable build by downloading the file named LATEST.TAR.GZ. In the summer of 1996, the latest stable build for UNIX was Perl version 5.002.

TIP
You may be tempted to try some of the code in the /PATCHES and /UNSUPPORTED subdirectories. These subdirectories contain work in progress and unstable code releases. Unless you like to work with buggy code, you probably will want to avoid these subdirectories and access only the "official" releases

Amiga

You can access Perl for Amiga by referencing the /PORTS/AMIGA subdirectory of the nearest CPAN location. To access the subdirectory directly, enter http://www.perl.com/ports/amiga into your browser. The most recent version of Amiga is version 5.002.

AOS

You can access Perl for AOS by referencing the /PORTS/AOS subdirectory of the nearest CPAN location. The most recent version of AOS is version 5.002.

Atari

Access the Atari Perl installation by accessing /PORTS/ATARI from CPAN. The most recent version of Atari appears to be version 4.035.

LynxOS

The most recent version of Perl ported to LynxOS is version 4.036, and you can access it by going to the /PORTS/LYNXOS subdirectory from CPAN.

Mac

The MacPerl home page lists the current version of MacPerl as version 5.0.7. Based on the date of this home page and on our access of this page during the summer of 1996, I estimate that this version is equivalent to UNIX version 5.001. The best place to access this installation is ftp://ftp.switch.ch/software/mac/perl/.

MS-DOS

The most recent port to MS-DOS of Perl, made in November 1994, is a preliminary port of version 5.0. You can locate this version of Perl at /PORTS/MSDOS/PERL5 from a CPAN site. The author of the product has issued a disclaimer about the product; you can access this disclaimer as the PERL5A.README file.

MVS

Version 4.036 of Perl is the most recent release for MVS. You can access this release at any CPAN site by accessing the /PORTS/MVS subdirectory.

NetWare

NetWare's newest version of Perl, 4.036, is available at the /PORTS/NETWARE CPAN subdirectory.

Windows 95 and Windows NT

These two operating systems have been combined, and the same version of Perl can be used for both. The current version of Perl that has been implemented for the Win32 port is version 5.001; you can access it directly at ftp://ftp.perl.hip.com/ntperl/. The most current release of Win32 Perl probably will be in the CURRENTBUILD subdirectory, and the file will be called 107-i86.ZIP. The source code is located in the file 107-SRC.ZIP. Information about the port is available at http://www.perl.hip.com/PerlFaq.htm.

OS/2

The 5.001 version of Perl has been ported to OS/2; you can find it at any of the CPAN sites under /PORTS/OS2.

QNX

You can find a port of version 5.0 of Perl for QNX at /PORTS/QNX of any of the CPAN sites.

VMS

VMS has been ported to version 5.0, but unfortunately, the port was not working at this time when this chapter was written (summer 1996). You can access the 4.036 port from any CPAN site in the /PORTS/VMS SUBDIRECTORY.

Xenix

Version 4.036 of Perl has been ported for the Xenix operating system; you can find it at /PORTS/XENIX on any CPAN site.

Linux

Version 5.001 for Linux is available at http://www.onshore.com/software/perl-linux.html.

Installation

This section contains the installation instructions for the most recent and stable port for the most common operating systems. For the most up-to-date information about a release of Perl for a specific operating system, check the CPAN site for that operating system.

UNIX Installation

You need to download the Perl installation file from the UNIX site listed in the preceding section of this appendix. The file will most likely be named LATEST.TAR.GZ. When you have the file, extract the files into a subdirectory.

In the new subdirectory that contains the Perl files, open the text file called INSTALL. This file contains detailed instructions about installing the version of Perl that you downloaded. Following is a synopsis of these instructions:

mv config.sh config.sh.old
This code renames the existing CONFIG.SH file.
sh Configure [options]
This code runs the Configure shell script, which attempts to find information about your system, run make on the Perl source, and install Perl in your system's binary subdirectory (usually, /USR/LOCAL/BIN). When you run Configure, you can specify options, such as specifying a different location for Perl or a different compiler.

Perl 5.0 can interface with a database through extensions. If you have these extensions installed on your system, Configure includes the extension if it can find the header files and libraries. Again, you have the option to inform Configure of the subdirectory in which the files are installed, if they are not in the standard directory that the C compiler searches for.

Table A.2 lists some of the Configure options and their impact. To see the full list of options, check the INSTALL file of the version of Perl that you downloaded.

Table A.2  UNIX Installation Configure Options

OptionResult
-DccSpecifies an alternative compiler
-hLists options
-OUses existing CONFIG.SH file but overrides some of the items
-desAccepts defaults and provides terse output
-DprefixSpecifies the directory in which Perl will be installed
-UusedlForces static compile of Perl

ON THE WEB
To find more information about Perl and UNIX, you should access the Perl FAQ at http://www.perl.com/perl/faq/index.html. Documentation from Larry Wall is available at http://www.atmos.washington.edu/perl/perl.html

Windows 95 and Windows NT

Installing Perl 5.0 for Windows NT or Windows 95 is relatively easy. After downloading the zipped file 107-i86, use WinZip to extract the files to the subdirectory that is included as part of the zipped file information. If you want to install Perl on your C drive, just specify that drive; the files will be installed in a subdirectory called PERL5.

After extracting the files, look for a README file called INSTALL.TXT. This file includes the most current information regarding the installation of Perl 5.0. Another file, README.TXT, includes other information, such as the GNU General Public License, the system requirements, and the differences between Perl for UNIX and Perl for Win32.

In addition to these text files, you might find one called WIN95.TXT, which details any problems with running Perl for Win32 on Windows 95. At the time when this book was written, some of the problems with running Perl for Win32 on Windows 95 had to do with some problems with the 16-bit shell, COMMAND.COM.

To install Perl for Win32, run INSTALL.BAT from a command prompt. This file adds Perl to the Registry, creates the \PERL5\BIN subdirectory (if it does not already exist), and adds this subdirectory to the path. In addition, if this version is an upgrade to an existing installation, the application renames the file that contains the existing version of PERL.EXE to include the version number (PERL.4.36.EXE, for example).

If you have any existing Perl scripts or libraries, you can copy them to the \PERL5\BIN subdirectory after the installation process.

You can compile PERL.EXE by using the source in the zipped file 107-SRC.ZIP. After downloading this file, extract the files into the same \PERL5 subdirectory that you used to extract the binary files. Perl 5.0 was compiled with Microsoft Visual C++, and you can compile the source code by accessing the makefile called PERL.MAK in \PERL5\EXE-SRC.

You also can use nmake to compile the PERL.EXE and PERLGLOB.EXE files.

ON THE WEB
You can find a FAQ on Perl for Win32 at http://www.perl.hip.com/PerlFaq.htm

MacPerl

The instructions for installing MacPerl are available at ftp://ftp.switch.ch/software/mac/perl/. Look for a file called MAC_PERL.INFO. Currently, the installation consists of four files: MAC_PERL_507R1M_APPL.BIN, MAC_PERL_507R1M_APPL.DISK1.BIN, MAC_PERL_507RLM_APPL.DISK2.BIN, and MAC_PERL_507RLM_TOOL.BIN.

You must be running System 7 to install MacPerl. In addition, you need the Metrowerks CodeWarrier C/C++ compiler (see http://www.metrowerks.com), the CWGUSI_164.SIT.BIN Socket Library, and the DB_185b.SIT.BIN Berkeley db library.

Follow the instructions given with Metrowerks CodeWarrier to compile.

The MacPerl home page is located at http://err.ethz.ch/~neeri/macintosh/perl.html, and an FAQ is available at http://www.unimelb.edu.au/~ssilcot/macperl-primer/home.html. A MacPerl primer is available at http://www.unimelb.edu.au/~ssilcot/macperl-primer/home.html.

OS/2

Download the zipped file that contains the Perl executable and associated files. At this time, the version of Perl for OS/2 is Perl 5.001 and Patchlevel "m." After you download the file, extract the files to your hard drive. Then open the README file to review installation instructions and last-minute information.

The current version of the file specifies that the Perl user needs to format his or her system for HPFS and then copy PERL5X.EXE AND PERLGLOB.EXE to a PATH subdirectory. PERL5.DLL is copied to a LIBPATH subdirectory, and a variable called PERL5LIB is set to any existing and new Perl library subdirectories.

Check the README file for additional information, and to see what other files and applications you might need to install and run Perl.

Linux

If you are using Slackware's Linux installation, a copy of Perl 5.001 is included with version 3.0. When you are installing Linux or using the package install tool, make sure that you install disk set D. This disk set includes the C libraries and GNU compilers, as well as Perl.

Other OSes

Each version of Perl for whatever operating system usually includes instructions with the installation files. If the installation files are compressed, you need to have the appropriate software to extract the files. You also want to look for any files named README, INSTALL, or SETUP.