If
you are tired of writing code to create forms, decoding form information,
or maintaining state between multiple forms, you can make your life
easier by using the freely available CGI modules for Perl 5. However,
unless you are familiar with programming, it will be difficult to
fully grasp how these modules work internally.
First, here is a list of the available modules. We will look
at an example that incorporates the functionality from some of these
modules shortly.
This is the core module that contains common methods (i.e.,
functions) that some of the other classes depend on. These include
methods to read form information (the module does not parse or decode
the data), log debug messages, implement socket I/O for maintaining
state, and access and manipulate data from environment variables,
such as the client's acceptable MIME content
types.
If you are familiar with object-oriented programming, Base.pm
represents the base class, from which other classes "inherit" methods
and data structures. The "child" classes can override the methods
from the base class to create modified functions, or implement new
ones.
This module consists of functions to handle the new multipart
forms generated by "file upload"--a feature new to Netscape 2.0.
The file upload feature allows users to send files on their local
machines as part of a form. This is a very powerful feature, but
decoding the data can be a hassle. So, you should use either this
module or the CGI_Lite module to handle multipart
forms.
You can parse and decode form and query data with this module.
That's all there is to it!
Have you ever wished you could create forms much more quickly
and easily than outputting a series of HTML tags?
If so, the Form module is the one for you! You no longer have to
remember how to create a radio button or a scrolled down list.
In addition, this module allows you to easily decode and parse
form and query data. The functions responsible for this are inherited
from the Base.pm and Request.pm
modules.
With this module, you can implement a "mini HTTP
daemon" which can be forked from a CGI application to maintain state
between multiple form invocations. The daemon sits on a port with
a relatively short timeout, waiting for a request. It then serves
the request and terminates. Now, imagine what will happen to your
host machine if the rate of process creation (i.e., forking) exceeds
that of termination.
You need to be careful when using this module to maintain
state, as it creates multiple processes to handle requests. If the
rate of process creation exceeds that of termination, your server
will become overloaded and may result in serious problems.
However, this module can be very helpful if used correctly,
as all socket I/O is handled by the module so that you don't have
to worry about such things as choosing the correct port number,
establishing the socket, or reading from the socket.
Though not a part of the official CGI module distribution
at the time of this writing, this module contains functions that
make it easier to output HTML headers. For example,
if you don't want a document to be cached, you can call a method
that will automatically output the Pragma and
Expires headers for you.
This module is independent, in that it does not inherit any
functionality from the base class. However, it is a very useful
module that allows you to format error messages sent to the server
log file or redirect them to the browser or another file.