Official Guide to Programming with CGI.pm

Internet Research

ISSN: 1066-2243

Article publication date: 1 August 1999

69

Citation

Brooks, T.A. (1999), "Official Guide to Programming with CGI.pm", Internet Research, Vol. 9 No. 3. https://doi.org/10.1108/intr.1999.17209caf.008

Publisher

:

Emerald Group Publishing Limited

Copyright © 1999, MCB UP Limited


Official Guide to Programming with CGI.pm

Official Guide to Programming with CGI.pm

Lincoln SteinJohn Wiley & Sons, Inc.New York, NY1998310 pp.ISBN 0-471-24744-8$29.99Available: Professional Reference and Trade Group, 605 Third Avenue, New York, NY 10158-0012; http://www.wiley.com/compbooks

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: HYPERLINK 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. BrooksSchool of Library and Information ScienceUniversity of Washington

Related articles