There is an object oriented and a procedural interface to the
Perl CGI library. We will be exclusively using the Object Oriented
interface.
To use the CGI module, include the following line your Perl
program: use CGI;
You must also instantiate a Perl CGI object. For example, to
create an object named "query", use: $query = new CGI;
The actual syntax for supplying an argument to a CGI object
method would be as follows (this example uses the header CGI method):
print $query->header({-type=>'image/gif', -expires=>'+3d'});
The arguments in the curly braces are HTML tag modifiers. The
arguments not in the braces are the contents between the open and
closing tags.
Naturally, like the rest of Perl, these arguments can be scalars,
arrays, or hashes. Like the rest of Perl, you never really know for
sure when to pass which. Like the rest of Perl, if you go with your
gut, it will probably almost always work out fine nonetheless.
Examples on the upcoming pages will demonstrate the syntax
involved for these different argument types.