[prev] [index] [next]

Example CGI.pm (cont)

An OO-style script (HelloScript.cgi)

use CGI;
$cgi = new CGI;
$name = $cgi->param("UserName");
print $cgi->header(), $cgi->start_html(),
      $cgi->p("Hello there, $name"),
      $cgi->end_html();

Output of script (sent to browser):

Content-type: text/html

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<HTML><HEAD><TITLE>Untitled Document</TITLE>
</HEAD><BODY><P>Hello there, John</P></BODY></HTML>