A Perl Library for Writing CGI Scripts
Hiding the details of creating HTTP headers, parsing query strings, and maintaining state
By Lincoln D. Stein
If you're writing CGI scripts in Perl, you'll want to consider using the CGI.pm module. This library handles many fill-out forms so that you can concentrate on the task at hand. The module is widely used and frequently updated. CGI.pm combines several useful functions:
- Parsing of CGI query strings.
- Shortcuts for creating HTTP headers.
- Shortcuts for creating fill-out forms easily with "sticky" elements.
- Simplified content negotiation with the browser.
- Functions for handling Netscape cookies, JavaScript, frames, and so on.
CGI.pm uses Perl 5's object-oriented style of programming. To use it, you'll need Perl 5.001 or higher Perl 5.003 is recommended. It runs correctly on all major platforms, including UNIX, Windows 95, Windows NT, and Macintosh. You'll find this module on the Internet in the Perl CPAN archives, or you can go directly to CGI.pm's home site; see "
Online." CGI.pm is available at this site in UNIX tar, Windows zip, and Macintosh sea archive formats.
Using CGI.pm
In CGI.pm, everything is done through a CGI object. At the beginning of your script, you create a new CGI object that parses the CGI parameters and stores the results within itself.