I've never used CGI.pm to produce HTML before and decided that it was high time I did so. My primary uses for Perl are sysadmin tasks and data munging and I've written only a few web applications.

In all of my programming endeavors I try to develop a cache of basic "templates" from which to build upon. My question is does anyone have an example of a Perl script that uses CGI to create a simple HTML document (e.g., displays a simple table) which passes W3C HTML Validation?

I have done a little research (though perhaps not as much as I could have) e.g., I perused some of the CGI tutorials/courses by Ovid and cut/pasted a couple of sample programs but I get errors followed by the message:

Sorry, this document does not validate as HTML 2.0
Note that I'm not criticizing Ovid, I deeply appreciate the fact that he's gone to so much trouble and have picked up some extremely useful concepts that will come in handy for later projects. I'm also fairly sure that it was not his intent that the examples I used be W3C compliant. I also composed a simple page using the NS composer which didn't pass either.

Is trying to conform to W3C standard desirable or overkill? Although my first attempts will be extremely simple, I don't want to start out by acquiring bad habits. Especially when I have a resource like the monastery at my disposal. TIA for any help.

--Jim


In reply to CGI.pm HTML vs. W3C HTML Validation by jlongino

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.