home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  

1.3 Availability

Unless you have had the good fortune of having a system administrator install Perl on your workstation, you will need to obtain and install a copy yourself.

Perl is distributed under the GNU Public License,[ 1 ] which says something like, "you can distribute binaries of Perl only if you make the source code available at no cost, and if you modify Perl, you have to distribute the source to your modifications as well." And that's essentially free. You can get the source to Perl for the cost of a few megabytes over a wire.

[1] Or the slightly more liberal Artistic License, found in the distribution sources.

At the time of this writing, there are two Perl distributions that run on Windows NT and Windows 95. There is the ActiveState port of Perl, called Perl for Win32, and starting with Perl 5.004, the standard Perl distribution includes support for Win32 systems. The two versions are largely compatible, with some of the Perl 5.004 code being based on the ActiveState port, but there are some differences. The programs and examples presented in this tutorial have been tested on both systems; when a distribution requires different code, we point that fact out. The architects of both distibutions have announced their intention to merge the distributions, but they have not yet announced a time frame for that to happen.

1.3.1 ActiveState Perl for Win32

The canonical source for the ActiveState Perl for Win32 distribution at the time of this writing is at http://www.activestate.com . You can also find the source and binaries for the Perl for Win32 distribution at CPAN. To use the CPAN archives, visit http://www.perl.com/CPAN for a mirror site close to you. The CPAN site will also provide the source distribution for the UNIX version of Perl and precompiled binaries for other platforms. If you're absolutely stumped, write and say "Where can I get Perl?!?!"

Perl for Win32 comes in a variety of flavors, in both source and binary distributions. Unless you have access to a C++ compiler,[ 2 ] you'll probably want to get the binary distribution that contains the Perl executables and libraries, pre-built and ready to use. You might also want to grab the source distribution for reference purposes, if you're familiar with C/C++.

[2] The Perl for Win32 distribution currently includes makefiles only for the Microsoft Visual C++ compiler.

You can choose from one of several different binary distributions: there's a standalone version of the Perl interpreter (Perl for Win32), a version for use as an ISAPI[ 3 ] extension with ISAPI compliant Web servers ( PerlIS), and an ActiveX scripting version ( PerlScript). If you choose either the ISAPI or the PerlScript version, you will still need the standalone version of the interpreter, because it contains the Perl libraries, documentation, and example files. Binary distributions exist for both DEC Alpha and Intel versions of Windows NT. At the time of this writing, the current release version of Perl for Win32 is based on Perl 5.003, and the build number is 306.

[3] For more on ISAPI and PerlIS, see Chapter 18, CGI Programming .

The standalone version of Perl for Win32 is easy to install; the distribution comes as a self-extracting executable. Just run the executable, select the directory to install into, and run the installation script as prompted by the installer. You'll probably need to re-logon (in Windows NT) or reboot (in Windows 95) to your workstation because the installation changes the PATH environment variable.

The Perl for Win32 distribution includes the Perl interpreter, the standard Perl libraries (useful collections of code that aren't part of the core language), and a number of Win32 extension modules. The Win32 extension modules either extend Perl to provide additional functionality for Win32 platforms or they provide functionality that is present in UNIX versions of Perl, but which is unimplemented or otherwise missing in Win32 versions. The distribution also includes help documentation (in HTML format) and example scripts that demonstrate the various features of Perl and the Win32 extensions.

Currently, if you're interested in either the ISAPI version of Perl, or PerlScript, you need to get the ActiveState distribution, because neither of these tools works with the standard distribution. Also, if you don't have convenient access to either the Microsoft or Borland C++ compilers, you'll definitely want to grab the binary ActiveState distibution.

1.3.2 Standard Perl Distribution

The standard Perl distribution can be found at http://www.perl.com/CPAN/ and compiles out of the box for several different platforms, including Windows NT. As we write this, the standard distribution is only available in source form; the binary distribution on CPAN is the ActiveState port. This scenario is likely to change by the time you are reading this, so you'll want to visit CPAN to investigate your options.

The source distribution of Perl 5.004 requires either the Microsoft Visual C++ compiler (versions 2.0 - 5.0) or the Borland C++ compiler (version 5.x). After you get the distribution, you should start with the readme.win32 file, which contains detailed instructions for building, testing, and installing the distribution.

Briefly, here's what you need to do to build and install the distribution (this example assumes you're using the Microsoft compiler, but using the Borland C++ compiler should be quite similar, except that you'll need to get the dmake make utility; see readme.win32 for details).

Extract the distribution using some utility that supports gzip and tar files, as well as long filenames. There are ports of both GNU gzip and tar available for the various Win32 platforms (you can find both at the Virtually UN*X site at www.itribe.net/virtunix or several other places on the Net), and these will work quite nicely. Alternatively, you might try one of the graphical zip archive programs (we recommend WinZip at www.winzip.com ).

Assuming you're using gzip and tar , execute the following (you might need to adjust the filename):

> gzip -dc perl5.004_01.tar.gz | tar xf -

If you're using WinZip or some other utility, make sure that you preserve the directory structure.

Next, edit the makefile ( Makefile ) in the win32 subdirectory of the distribution and make sure that you're happy with the values for the install drive and directory.

Then, execute the following commands from the win32 subdirectory of the distribution to build, test, and install the distribution. This assumes that you have the proper environment variables (LIB, INCLUDE, etc) set up for your compiler (this assumes nmake is your make utility).


(Build all of Perl)

nmake test

(Test your distribution)

nmake install

(Install to the target dir. in the Makefile)

Assuming everything is built correctly, you just need to add the bin subdirectory of the installation target directory to your path. For example, if you installed the Perl distribution to c:\Perl , you'll want to add c:\Perl\bin to your path.

Finally, restart your machine to get the environment changes, and you're ready to go. We strongly recommend getting the libwin32 package from CPAN, and installing it as well. We'll be discussing several of the extensions provided by libwin32 throughout this book (the ActiveState distribution includes most of these extensions already). Installation of libwin32 is easy. Simply download and extract the file, and then execute the following commands from the directory to which you extracted the files:

perl Makefile.PL


nmake test

nmake install

1.3.3 Windows NT and Windows 95

A word of warning is probably in order here: Windows 95 users can expect significantly different functionality from their Perl distribution than Windows NT users. For various reasons, some of the Win32 modules don't work on Windows 95. The functionality required to implement them may be missing on Windows 95, or bugs in Windows 95 may prevent them from working correctly. We'll explore some of the specifics in later chapters, but for now remember that some of the examples and concepts presented in this book require Windows NT.