Kudos to the other posters for their helpful advice. I concur.

I did want to add something. Perl has an handy feature sometimes called HERE documents. They work just like quotes but even better. They start with: << followed by a string. They end with the same string at the begining of a line. (see example below.)

Using this, you can encapsulate the entire HTML page you intend to return in one quoted chunk. Small pieces of the page can be included as perl variables that you constructed previously. Virtually none of the characters in the HERE block need to be escaped, exception for $ signs (any others?). Doing this makes your code MUCH easier to read. This technique amounts to a quick, crude Templating system -- a good thing, but that's another post. In the example below I use "MESSAGE1" as my string:

#!/usr/bin/perl # UNTESTED use CGI; use strict; use warnings; # do some processing here # create my output strings # IN real life these would be do something real... my $myTable = "some HTML string"; my $myOtherTable= "some HTML string"; # # Print the HTML # print CGI::header; print <<MESSAGE1; <html> <body> <center> <table border=0 cellpadding=0 cellspacing=0 width=600> <tr> <td align="left"><img src="img/citi.gif" width=150></td> <td align=right><img src="img/travelers.gif" height=60></td> </tr> </table> $myTable $myOtherTable ... lots of HTML deleted from here for brevity ... </center> </body> </html> MESSAGE1

-------------------------------------
Nothing is too wonderful to be true
-- Michael Faraday


In reply to Re: a question about working with the forms and array by freddo411
in thread a question about working with the forms and array by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.