Official Guide to Programming with CGI.pm

Lincoln Stein

John Wiley & Sons, Inc.

New York, NY

1998

310 pages

ISBN 0-471-24744-8

$29.99

Keywords CGI, Common Gateway Interface, Web Programming, Perl

CGI.pm, the Common Gateway Interface Public Module, is a standard set of web tools for Perl, the most common programming language for creating web applications. The primary reason for using CGI is passing information from one web page to another: The classic application is collecting information with a fill-in form and then sending these inputs to a cgi page that would process them. Writing your own script to isolate these inputs is daunting, the predecessor library of tools, cgi-lib.pl, helped, but was tricky. Steinís important accomplishment is creating a set of tools that provide power, but shield the web programmer from too many details. The difficult task of parsing input is now a simple call to a param() function. If it did little more than this, it would be justifiably famous and widely used.

This book is an introduction to the CGI.pm module formerly only available at http://stein.cshl.org/WWW/software/CGI/cgi_docs.html. This web document is for the serious programmer, while beginners will find this book much more accessible. It covers basic html coding, classic cgi widgets like forms, buttons, text boxes and so on, and gives several comprehensive examples such as a multipart form and a guest book. CGI.pm simplifies html coding to the point of replacing it. One must conclude that any web page, beyond the very simplest, should be written as a cgi page. Stein requires, however, the reader to possess a rather sophisticated understanding of Perl. Perhaps this should be the second book you buy; the first should be a basic Perl primer. For example, many of the examples are written in an economical, but sophisticated manner that call themselves in absence of parameters (e.g., the first time they run). The true beginner might expect the html and cgi scripts to be different, an expository style that would aid the audodidact.

CGI is now object oriented, although this functionality does not have complications for most work since the fundamental object is implied. Stein gives an example of creating several CGI objects and manipulating them independently, but the book lacks truly compelling examples of the object oriented aspects of CGI. Stein covers other advanced issues such as maintaining state with hidden fields in multipart forms, and saving parameters to a file. Stein illustrates a method for debugging CGI scripts, still one of the greatest challenges since errors can lurk in the Perl code, the passing of parameters or the html. Finding errors is easier if one can debug CGI scripts from the command line.

There is a particularly useful linkage made to JavaScript, which can be used to validate form entries. The combination of Perl, CGI, HTML and JavaScript is very powerful, and all of this can be accomplished by writing a cgi script.

The last third of the book is a very useful reference guide to CGI.pmís functions and features. This book should be part of every web programmerís library.

Terrence A. Brooks

School of Library and Information Science

University of Washington

Seattle, WA 98195-2930

tabrooks@u.washington.edu