Installing Perl

Overview
Objectives
Installing Apache
Installing Perl
Lesson 1
Hello World
Anatomy of a CGI Program
Hello World with CGI.pm
Lesson 2
HTML Forms and DOM
POST and GET
A Form Example
Lesson 3
Cookie Tutorial
Database Tutorial

Software Links
FAQ / Terminology
Contact the Author

 

In order to write Perl CGI programs, we'll need to make sure that Perl is installed on your system. To check if it is, start up a command window and type in

perl -v

and you should be greeted with something like the following:

This is perl, v5.6.1 built for i686-linux

Copyright 1987-2001, Larry Wall

Perl may be copied only under the terms of either the Artistic License or the GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on this system using `man perl' or `perldoc perl'. If you have access to the Internet, point your browser at http://www.perl.com/, the Perl Home Page.

If perl is not installed, then you will need to install it before proceeding.

Windows Installation

Visit http://www.activestate.com and download the latest release of ActiveState Perl (the current build when this was written is Perl 5.6.1 Build 631). Double-click on the installer and follow the instructions.

Repeat the test given above and verify that perl is now working. You should now have an "ActiveState ActivePerl" item in your Start Menu. Run the program called "Perl Package Manager", which will run a perl program that displays something like this:

PPM - Programmer's Package Manager version 3.0 beta 3. Copyright (c) 2001 ActiveState SRL. All Rights Reserved.

Entering interactive shell. Using Term::ReadLine::Stub as readline library.

Type 'help' to get started.

ppm> install CGI

Type in "install CGI" to install the CGI module for perl. The installer will note any dependencies that need to be met before CGI.pm can be installed, and it will automatically get them for you. After it finishes, close the window and you're ready to start coding.

UNIX/Mac OSX

Installing Perl under UNIX differs from distribution to distribution, but odds are good that it is already installed. If it isn't, then consult your documentation for the manner in which it should be installed.

After making certain that Perl works, we will need to ensure that the CGI module is installed. As the 'root' user, you will need to run the Comprehensive Perl Archive Network (CPAN) to install it:

# perl -MCPAN -e shell

cpan shell -- CPAN exploration and modules installation (v1.59_54)
ReadLine support enabled

cpan> install CGI

This will download the latest source version of the CGI module and it will compile it for your version of Perl. It will also download any requirements for the CGI module to run (like the HTTP and URI modules).


All pages written by Craig Kelley unless otherwise specified. Please use the Contact link from the menu to submit changes or suggestions. Permission is given to use this tutorial in any way you wish including re-publishing or "mirroring". The most up-to-date version of this document currently resides at http://inconnu.isu.edu/~ink/perl_cgi.

This page updated: May 6, 2002 22:21