Most 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.
NOTE: 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 INSTALL 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 README.xxx, 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 Section 2.4" 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.
Typically, 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.
The 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 #!
line to point to
the right interpreter.
The files in the t/ and lib/ subdirectories, although arcane in spots, can also serve as examples.
Since 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.
You 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, and 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.
The canonical source for the ActivePerl distribution at the time of this writing is at http://www.activestate.com/. Included in the distribution are:
Binary for the core Perl distribution
IIS plug-in for use with ISAPI-compliant web servers
ActiveX scripting engine
Manager for Perl modules and extensions
The ActivePerl binary comes as a self-extracting executable that uses the standard Win32 InstallShield setup wizard to guide you through the installation process. By default, Perl is installed into the directory C:\Perl\version, where version is the current version number (e.g., 5.005). Unless you choose to customize your setup, the default installation does not modify your registry other than to add an entry so you can uninstall Perl. For information on customizing your installation, see the Win32 FAQ on the ActiveState web site. The installation also associates the file extension .pl with Perl and adds the directory into which you installed Perl to your PATH environment variable.
The standard Perl distribution is available from CPAN, where you'll find binary and source distributions for Perl 5.004 for both Windows NT and Windows 95, and the source distribution for Perl 5.005. You can get the binary for Perl 5.004 as either a .tar.gz file or a .zip file. The source distributions come as .tar.gz files, which you can extract using a utility that supports gzip files, tar files, and long filenames. Ports of both GNU gzip and tar are available for the various Win32 platforms, or you can use a graphical zip archive program such as WinZip. Make sure you preserve the directory structure when you unpack the distribution.
To install from the source, you need the Microsoft Visual C++ compiler, the Borland C++ compiler, or Mingw32 with either EGCS or GCC. You also need a make utility. Microsoft Visual C++ comes with nmake, or you can use dmake.[1] Once you have the distribution, start by reading the file README.win32. Next, edit the file Makefile in the win32 subdirectory of the distribution and make sure that you're happy with the values for the install drive and directory.
[1] See the file README.win32 for information on obtaining Mingw32 and a Win32 dmake port.
Then execute the following commands from the win32 subdirectory of the distribution to build, test, and install the distribution. This example assumes that you have the proper environment variables (LIB, INCLUDE, etc.) set up for your compiler and that nmake is your make program.
> nmake Build all of Perl > nmake test Test your distribution > nmake install Install to target directory, as specified in the Makefile
Assuming everything is now 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 so the environment changes take effect, and you're ready to go.
If you want to install the Perl 5.004 binary, you can do so either from the command line or from Windows. To install from the command line, cd to the top level of the directory into which you unpacked Perl and type:
% install
From a window, click on the install.bat icon. That should initiate the installation, but if it doesn't, it will put you into the command shell in the correct directory. At that point, type:
> perl\bin\rl install.bat
The setup script then asks you a few questions such as where you want to install Perl and whether you want to install HTML versions of the documentation. It then confirms your responses and does the installation. When it's done, it gives you some information about setting environment variables and then terminates. At that point, you can start running Perl scripts.
A word of warning: 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.