Official Guide to Programming with CGI.pm
John Wiley & Sons, Inc.
New York, NY
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.
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