Äîęóěĺíňŕöč˙
HTML CSS PHP PERL äđóăîĺ

Installing Perl

 
Previous Table of Contents Next

Installing Perl

To play with Perl, you first have to install it. Perl's installation is designed to be easy and error free. In fact, as part of the installation steps, Perl should do a self-test to make sure that it's okay. The installation procedures vary widely depending on what operating system you have. So, to get things moving, pick which operating system you have from the sections here, and follow along.

Stop! Wait! Maybe You Already Have Perl

Before you go through all the trouble to install Perl on your system, you should check to see whether you already have it. Some Unix vendors ship Perl with the operating system. Windows NT comes with Perl as part of the Windows NT Resource Kit (but that version is a bit old). To see whether you have Perl properly installed on your operating system, you need to get to a command prompt.

Under Unix, simply log in to the system. If you have a graphical environment, you need to open a terminal window. After you've logged in or opened your window, you may see a prompt like this:


$


It might be a % or it might look like bash%, but either way, it is called the shell prompt or command prompt. For the first few hours, you'll need to be at this prompt to interact with Perl.

To see whether Perl is properly installed on your system, type the following (but not the $ prompt):


$ perl -v


Either the system responds with an error message such as command not found, or Perl responds and prints its version number. If Perl prints its version number, it's installed. You probably do not have to reinstall it.

Watch Out!

The version number reported should be at least 5—perhaps 5.004, 5.005, 5.6, 5.8, and so on—but no lower. If Perl responds with a version of 4.x, you must install a new copy. Perl version 4 is old, buggy, and no longer maintained; few of the examples in this book will work with Perl version 4. At the time of this writing, 5.8.6 is considered the current version of Perl.


To see whether Perl is properly installed on a Windows machine you need to get to an MS-DOS prompt, similar to Figure 1.1.

Figure 1.1. You can check your version of Perl at this DOS prompt.


At that prompt, type the following (but don't repeat the prompt):


C:\> perl -v


If Perl is properly installed, it answers with its version number. As noted in the previous caution, it should be at least version 5. If MS-DOS replies with Bad command or file name, you need to install Perl properly.

On the Macintosh (running MacOS), you can check to see whether Perl is installed by running File Find (Command-f) for 'MacPerl' as shown in Figure 1.2. If the application is found, open it and look at the "About MacPerl" option under the Apple menu. You should have at least Version 5.2.0 Patchlevel 5.004; otherwise, you should install a new version of MacPerl.

Figure 1.2. Looking for Perl on the Macintosh.


Newer Macintosh systems run Mac OS X. Underneath the point-and-click interface, there is a Unix operating system. To get a shell prompt (so that you can follow the Unix instructions) go to Finder, Applications, Utilities and select Terminal. You should see a window similar to Figure 1.3.

Figure 1.3. Mac OS X Terminal, with Perl version output.


Generally for Mac OS X, follow the Unix instructions in this book. There are extensions particular to Mac OS X that you can download from CPAN.

Installing Perl on Windows

To install Perl under Windows, keep in mind that, as with many things in life, you can take the Easy Way or the Hard Way. If you're proficient with a C compiler and the tools needed in a development environment—makefiles, shells, and so on—you can take the Hard Way and build your own Perl from scratch. The source to the perl interpreter is free for you to look at, modify, and change to suit your needs; see Hour 16, "The Perl Community," for details. Building Perl from scratch under Windows is not easy and probably more hassle than it's worth for most people.

Installing Perl the Easy Way really is easy. ActiveState Tool Corp. provides a self-installing Perl distribution, and installation works as it does for any other Windows application, as shown in Figure 1.4. This Perl is distributed under the ActiveState Community License, which you should read. The URL is http://www.ActiveState.com.

Figure 1.4. Installing Perl under Windows with ActiveState.


This is exactly the same Perl you would get if you had built it yourself. ActiveState has simply done the hard parts for you and wrapped it up with an installation program. ActiveState also offers commercial support for Perl, if you require it, and offers add-on products such as debuggers and other development tools and libraries.

Did you Know?

You can go to ActiveState's Web site to get the latest version of Perl.


Installing Perl on Unix

To install Perl on Unix, you need a couple of things. First, you need a copy of the Perl source bundle. You can always download the latest bundle from the Downloads area of http://www.perl.com. You can find multiple versions there, but the one you want is always labeled "Stable" or "Production." You also need an ANSI C compiler. Don't worry if you don't know what that means. Perl's configuration program checks for one, and if the compiler is not there, you can install a prebuilt version.

By the Way

If your Unix has a system for installing prebuilt packages, you may be able to install a prebuilt version of Perl. Linux, Solaris, AIX, and other Unixes have prebuilt bundled versions of Perl that can be installed easily. Consult your documentation on where to obtain these packages.


After you have the Perl source bundle—which comes in a file named something like stable.tar.gz—then you need to unpack and install it. To do so, enter these commands:


$ gunzip stable.tar.gz

$ tar xf stable.tar


These commands take a while to run. If you don't have the gunzip decompression program, you can obtain a copy from http://www.gnu.org. The program bundle is called gzip. When you're finished unpacking, type the following command at a prompt:


$ sh Configure


The configure program starts and asks you a lot of questions. If you don't know the answers to most of them, that's fine; just press Enter. The default answer is usually the best one. Perl can be built without problems on almost any Unix system imaginable. When that's all done, type this command:


$ make


Building Perl takes quite a while. Get some coffee. If you have a slow system, get lunch. When the build is complete, type two more commands:


$ make test

# make install


The make test command ensures that Perl is 100 percent okay and ready to run. To run make install, you might need to be logged in as root—that's why the prompt is #, root's prompt, in the example—because it wants to install Perl into system directories.

When make install is correct, you can test Perl's installation by typing the following at the prompt again:


$ perl -v


If this command works, congratulations!

Did you Know?

You can go to http://www.perl.com for the latest version of Perl.


Installing Perl on Mac OS

By the Way

If your Macintosh is running the new operating system Mac OS X, it is essentially a Unix machine and you should generally follow the instructions for Unix in this book. Mac OS X ships with a recent version of Perl and should already be installed.


The latest release of the Macintosh Perl—called MacPerl—is available from the CPAN ports directory. To get the release, you need to go to http://www.perl.com/CPAN/ports/mac and download the installation file from there. You should download the most recent version of MacPerl appl.bin from that directory. Install it by using StuffIt Expander to extract the MacPerl installation program from the downloaded file, and then running the installation program.

When you're finished, you will want to set up a helper for the Perl documentation reader, Shuck, which was installed with MacPerl. MacOS 8 users can do this in the Internet Control Panel by selecting File Mapping from the Advanced menu and adding a file extension mapping for .pod to the Shuck application. This will give you easier access to the documentation. You might also want to set up mappings for .ph, .pl, .plx, .pm, .cgi, and .xs (all extensions used by Perl) to the MacPerl application. Be sure to set the file type to 'TEXT'.

MacOS 7 users will have to use the InternetConfig utility to perform similar mappings. In the InternetConfig, select Helpers, and add a new helper application shuck for .pod. Also add helpers for the other extensions mentioned previously to the MacPerl application.

    Previous Table of Contents Next
    © 2000- NIV