Object-oriented CGI script

In object-oriented mode, the functions of CGI.pm are stored in a variable, named $q in this case. The new() functions is a constructor that creates a CGI object in memory. This object does the work of parsing script parameters and environment variables. The functions of the object are accessed through the -> operator.
-> must have an object to the left and a function to the right.

The function names are the same as in the functional programming style. Accessed through an object, they only must be addressed differently.

#!/usr/local/bin/perl -w

use CGI;

$q = new CGI; # instantiate new CGI object

print $q->header(),
      $q->start_html(-title=>"hello",
                        -bgcolor=>'white'),
      $q->h1('Starting CGI scripting'),
      $q->p('All the things you need for scripting');

print $q->ol(
      $q->li(patience),
      $q->li(endurance)
      );

print $q->hr();

$action = "http://people.cs.uchicago.edu/~wfreis/cgi-bin/reflector.pl";
$method = "post";

print $q->h3("Forms");
print $q->start_form($method, $action),

      $q->textfield(-name=>"textfield1",
                    -size=>"50",
                    -maxlength=>"50"),
$q->br,
$q->submit(-name=>"submit",
           -value=>"Submit"),

$q->endform();

print $q->end_html();

See the output.