1. Home
  2. Computing & Technology
  3. Perl

Working with CGI.pm In-Depth - Creating an HTML Document

From About.com

5 of 5

Last But Not Least

When you finally reach the end of your HTML document, as with most HTML tags you'll need to close it out. This is easily done with the function that sits opposite start_html, which is simply end_html. All this does is print out your closing </html> tag and finish out the page, but for style purposes it's the best choice.

Let's take a look at the entire script in one big statement, and the output it produces:

print $cgi->start_html(
-title => 'My CGI.pm Web Page',
-meta => {
'keywords' => 'perl, perl cgi, cgi.pm',
'description' => 'cgi.pm tutorals'
},
-style => {
-src => '/css/main.css'
},
-script => {
-language => 'javascript',
-src => '/javascript/main.js'
}
); print $cgi->end_html;
And the full output of our script (just think of all the HTML you won't have to write!):
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-US"><head><title>My CGI.pm Web Page</title>
<meta name="keywords" content="perl, perl cgi, cgi.pm" />
<meta name="description" content="cgi.pm tutorals" />
<link rel="stylesheet" type="text/css" href="/css/main.css" />
<script src="/javascript/main.js" type="text/javascript"></script>
</head><body></body></html>
Explore Perl
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. Perl
  4. CGI & Web
  5. Working with CGI.pm In-Depth - How to create an HTML document header with CGI.pm

©2009 About.com, a part of The New York Times Company.

All rights reserved.