Unfortunately, much of what your CGI
applications will be sending to the Web browser will include the
double-quote mark. It becomes tedious, especially for long blocks
of HTML code, to make print statements for every line of HTML and
to escape every occurrence of a double-quote with a backslash.
Consider the following table definition:
print "Content-type: text/html\n\n";
print "<TABLE BORDER = \"1\" CELLPADDING =
\"2\" CELLSPACING = \"2\">";
print "<TD ALIGN = \"center\">Email</TD>";
print "<TD ALIGN = \"center\"> <A HREF =
If any one of those backslashes are
missing, the whole script breaks down. And this is a very small
block of code!
One solution to the sending of large
blocks of HTML code which incorporate the double-quote is to use
the "here document" method of printing. The "here document"
method tells Perl to print everything within a certain block of
boundaried code. The "here document" uses the generic
[Text to be printed]
For example, this code will print out
the basic HTML header:
In short, the "here document" method of
printing tells the Perl interpreter to print out everything it
sees (print <<) from the print line until it finds the text
boundary marker specified in the print line (end_of_html_header).
The text boundary marker can be anything you like of course, but
it is useful to make the flag descriptive.
Further, the ending flag must be
"exactly" the same as the flag definition. Thus, the following
code will fail because the final flag is not indented
print <<" end_of_header";
The final "end_of_header" tag should
have been indented four spaces, but it was not indented at