I would like to suggest the following modifications:

   #!/usr/bin/perl -wT    #set warn and taint flags
   use strict;   #strict syntax checking

   use CGI qw/:standard :html3/;
   print "Content-type: text/html\n\n";
   etc.

You don't need the ":html3" for this little snippet, but you soon will if you start using the html shortcuts (recommended) and want to do anything more than simple pages. The standard feature set for CGI.pm (loaded by ":standard") only supports HTML 2.0 tags.

With "use strict;", you will need to declare $foo as "my $foo =..."

See the perl documentation for examples of the html shortcuts, which IMO make perl CGI progs which generate HTML far more readable, and also for more info on perl warnings, taint mode, and strict.


In reply to Re: CGI.pm question by virtualsue
in thread CGI.pm question 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.