CGI Programming on the World Wide Web

Previous Appendix A
Perl CGI Programming FAQ
Next
 

A.2 Modules

Should I use the Perl CGI modules to code all my CGI scripts? Isn't it easier to do it myself?

It really depends on what you are trying to do. The CGI modules should generally be used for heavy-duty CGI scripts. For simple scripts, it is far easier and quicker to roll your own or use CGI Lite (current version is v1.62 http://bytor.engr.wisc.edu/pub/perl/cpan/authors/id/SHGUN/CGI_Lite-1.62.pm.gz). If you really want, you can even use the Perl 4 cgi-lib.pl library (http://www.bio.cam.ac.uk/web/form.html).

How do I figure out how xyz module works?

Most modules have manpages embedded within the module itself. If that is the case, you can use the pod2man script to view the manpage:

% pod2man module.pm | nroff -man | more  

What CGI or WWW libraries are available for Perl4? Which should I use, and why?

The most widely used CGI library for Perl 4 is cgi-lib.pl written by Steven Benner (http://www.bio.cam.ac.uk/web/form.html). It is very, very simple to use!

What CGI modules are available for Perl 5? Which should I use, and why?

CGI::* Modules

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

These modules allow you to create and decode forms as well as maintain state between forms.

CGI Lite

(http://bytor.engr.wisc.edu/pub/perl/cpan/authors/id/SHGUN/CGI_Lite-1.62.pm.gz)

An alternative to the CGI::* modules. It is a glorious Perl 5 version of cgi-lib.pl.

Both of these modules have the ability to decode the multipart/form-data encoding scheme.

Why are so many of these CGI Perl libraries object oriented? I don't know O-O programming. Aren't there simpler libraries for non-programmers to use? How hard can it be?

You can use cgi-lib.pl (http://www.bio.cam.ac.uk/web/form.html), which is not object oriented, because it was designed for Perl 4.

But, using the Perl 5 O-O libraries is a piece of cake! Here is a simple example that uses CGI Lite (http://bytor.engr.wisc.edu/pub/perl/cpan/authors/ id/SHGUN/CGI_Lite-1.62.pm.gz) to print out form data:

#!/usr/local/bin/perl5
use CGI_Lite;
print "Content-type: text/plain", "\n\n";

$cgi = new CGI_Lite ()
$cgi->parse_form_data ();
$cgi->print_form_data ();
exit (0);


Previous Home Next
Introduction Book Index CGI and the WWW Server

HTML: The Definitive Guide CGI Programming JavaScript: The Definitive Guide Programming Perl WebMaster in a Nutshell