[Appendix A] Perl CGI Programming FAQ
Author: Shishir Gundavaram
Date: Tue Aug 26 16:28:36 1997

#

| Appendix A |

# A. Perl CGI Programming FAQ

Contents:
Introduction
Modules
CGI and the WWW Server
Specific Programming Questions
Security

## A.1 Introduction

### Why does my HTML page/form need a script?

There are times when you might want to have some dynamic information (information that is not constant) in your HTML documents. This could include simple information such as the date and time, or a counter that displays "You are visitor number xxx", but it could also include such things as pie charts/graphs based on user input, results from searching a database, or animations. And the only way you can produce results like these is with CGI scripts (though you can also do so with client-side applications like Java and JavaScript, but that's a totally different story!).

### What does CGI stand for?

Here is an excellent description that my editor, Andy Oram, wrote up:

Common

  Assures you that CGI can be used by many languages and interact with many different types of systems. It doesn't tie you down to one way of doing what you want.

Gateway

  Suggests that CGI's strength lies not in what it does by itself, but in the potential access it offers to other systems such as databases and graphic generators.

Interface

  Means that CGI provides a well-defined way to call up its features--in other words, that you can write programs that use it.

### What is a script, anyway? What can I do with a script?

Simply put, a script is a program! OK, OK, there are semantic differences between the two words. If you really want to know, pick up a book on computer programming (or is that computer scripting :-)

You can create a lot of magic by writing a CGI program/script. You can create graphics on the fly, access databases and return results, and connect to other Internet information servers.

### What is Perl and why do so many people use it for CGI?

The answer is located in the first three lines of the Perl manpage:

> Perl is an interpreted language optimized for scanning arbitrary text files, extracting information from those text files, and printing reports based on that information.

Most CGI applications involve manipulating data in some fashion and accessing external programs and applications. Perl provides easy-to-use tools that make these tasks a cinch.

### Is there a book or online docs on CGI and/or Perl programming?

Here is a list of books on CGI and Perl. I got this list from Cye H. Waldman:

- NCSA CGI Documentation (http://hoohoo.ncsa.uiuc.edu/cgi)

- Forms Tutorial (http://robot0.ge.uiuc.edu/~carlosp/cs317/ft.4-5.html)

- CGI FAQ (http://www.best.com/~hedlund/cgi-faq

- Perl FAQ (<http://mox.perl.com/perl/faq/index.html)

- WWW Security FAQ (by Lincoln Stein) (http://www-genome.wi.mit.edu/WWW/faqs/www-security-faq.html)

- CGI Security FAQ (by Paul Phillips) (http://www.cerf.net/~paulp/cgi-security/safe-cgi.txt)

- WWW FAQ (http://boutell.com/faq)

Here is a table of books and CD-ROMS about CGI and Perl:

Author | Title | Publisher | Medium | Price
--- | --- | --- | --- | ---
Christian Neuss & Johan Vromans | The Webmaster's Handbook: Perl Power for Your Web Server (http://zelda.thomson.com/itcp/neuss/neuss.html) | Int'l Thomson | CD-ROM | $30
William E. Weinman | The CGI Book | New Riders | CD-ROM | $45
Garbus et al. | Perl Programming Unleashed (March 1996) | Sams.net | CD-ROM | ??
Steven E. Brenner & Edwin Aoki | Introduction to CGI & Perl: WebScripts http://www.mispress.com/introcgi /online_app.html) | MIS:Press/M&T Books |  | ??
Ed Tittel et al. | Perl 5 Programming Secrets (March 1996) | IDG Books | CD-ROM | ??
Mitzelfelt | Special Edition Using Perl | Que |  | ??
Shishir Gundavaram | CGI Programming on the World Wide Web (http://www.ora.com/gnn/bus/ora/item/cgi_prog.html) | O'Reilly |  | $30
Rob Farrel | The Official 60 Minute Guide to CGI Programming with Perl (http://db.www.idgbooks.com/database/book/isbn/generic-book.tmpl?query=1-56884-780-7) | IDG Books |  | $20
Ed Tittel et al. | Web Programming Secrets | IDG Books | CD-ROM | $40
John Deep | Developing CGI Applications with Perl (Dec 1995) | Wiley |  | $30
Jon Orwant | Perl 5 Interactive (February 1996) | Waite |  | $30
Reggie David | Perl 5 How-To (Spring 1996) | Waite | CD-ROM | $40
Eric Herrmann | Teach Yourself CGI Programming with Perl in a Week | Sams.net |  | $30
Walnut Creek CDROM | Perl (Collected resources, archives, tutorial, examples, source code, etc.) | Walnut Creek CDROM | CD-ROM | $40
Carl Dichter & Mark Pease | Software Engineering with Perl (This is an advanced text for software professionals; it is not a tutorial.) (http://www.prenhall.com/013/ 016964/ptr/01696-4.html) | Prentice Hall | Disk | $30
Ellie Quigley | Perl by Example | Prentice Hall |  | $27
John December & Mark Ginsburg | HTML & CGI Unleashed | Sams.net | CD-ROM | $50
David Till | Teach Yourself Perl in 21 Days | Sams | Print | $30
Larry Wall & Randal L. Schwartz | Programming Perl | O'Reilly | Print | $30
Randal L. Schwartz | Learning Perl | O'Reilly | Print | $25
Ed Tittel et al. | Foundations of WWW Programming with HTML and CGI | IDG Books | CD-ROM | $40
Eric Lease Morgan | Teaching a New Dog Old Tricks (Mac-based WWW Starter Kit with Server) (http://152.1.24.177/teaching/manuscript/0010-title-page.html) |  | Online | Free!
Susan B. Peck & Stephen Arrants | WebSite: Everything You Need... (This is a complete Website kit for Windows NT 3.5 or Windows 95) (http://www.ora.com/gnn/bus/ora/item/web11.html) | O'Reilly | CD-ROM | $249
Lincoln D. Stein | How to Set Up and Maintain a World Wide Web Site (http://www-genome.wi.mit.edu/WWW/) | Addison-Wesley |  | $29
Jonathan Magid et al. | The Web Server Book | Ventana | CD-ROM | $50
net.Genesis & Devra Hall | Build a Web Site | Prima |  | $35
David Chandler | Running a Perfect Web Site | Que | CD-ROM | $40
Jon Weiderspan & Chuck Shotton | Planning & Managing a Web Site on the Macintosh | Addison-Wesley | CD-ROM | $40

### Is there a mailing list or newsgroup for this kind of thing?

There is a very useful newsgroup: comp.infosystems.www.authoring.cgi, that is "monitored" by numerous CGI experts. However, you should not post a question to this group (or any other group, for that matter), until you have read the FAQ.

Various mailing lists for CGI and the Web exist, as well. Here are two of the most popular:

cgi-perl-request@webstorm.com [http://www.webstorm.com/local/cgi-perl]

This list is for those who are writing or interested in writing Perl 5 modules for CGI. It is not intended for any type of CGI support.

Tim Bunce (Tim.Bunce@ig.co.uk) wrote several elegant and useful CGI modules, although they are currently maintained by Lincoln Stein (lstein@genome.wi.mit.edu). These modules are located at:

http://www-genome.wi.mit.edu/WWW/tools/scripting/CGIperl

Lincoln has also written an excellent book on the Web and CGI (see the preceding table).

libwww-perlrequest@ics.uci.edu [http://www.ics.uci.edu/WebSoft/libwww-perl/archive]

libwww-perl is a Perl library that provides a simple and consistent programming interface to the Web.

You can access the Perl 4 distribution at:

http://www.ics.uci.edu/pub/websoft/libwww-perl

The Perl 5 libwww modules are located at:

http://www.os/oslonett.no/home/aas/perl/www

Are there archives on the net of mailings or postings about this?

Yes, look at:

The Usenet Newstand (http://CriticalMass.com/Concord/)

All of the comp.infosystems.www.* newsgroups are archived. In addition, the cgi-perl and libwww mailing lists are archived as well.

Set UID/GID Wrapper |  | Modules