This time we're going to take a close look at the start_html, which is used to generate the start of our actual HTML document. Once we've sent our document headers and told the client to expect HTML, we need to send it the proper data. Again, for these examples, we will just be printing HTML to the command line of our system, so there's no need for an actual web browser.
To start with, lets look at the default output of CGI.pm's start_html function:
#!/usr/bin/perl -wRunning this program will generate the following output:
use strict;
use CGI;
my $cgi = new CGI;
print $cgi->start_html;
<?xml version="1.0" encoding="iso-8859-1"?>With the default value, it's sending a valid XHTML 1.0 Transitional header, but there's one glaring problem. If you scan down, you'll see that the page's title tag says Untitled Document - and we don't want to be outputting untitled documents! This brings us to our first attribute for the start_html function, the one that gives us a title.
<!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>Untitled Document</title>
</head><body>
