No criticism will be considered too minor.

Around here, that's a challenge. :)

A couple of comments:

  1. Get into the habit of taint-checking, via -T. You'll find straightway that you need to de-taint param("sort"), since somebody could sneak in something that would corrupt the SQL statement you're building.
  2. use strict; will keep you out of trouble, as well. (And it would have pointed out one of the problems below.) use strict; sooner.
  3. Insteading of saying "Perl (vs. 5)" in a comment, write
    require 5.0;
    Then Perl will enforce the version requirement for you.
  4. You need to think through your error handling. In particular, what do you want the user experience to be if either you fail to connect to the database or if your query fails to execute?
  5. Add error checking to $sth->execute();
  6. What do you intend to do with $style? Never mind. I looked, but didn't at first see where you were using it.

The rest looks O.K. at a casual glance. You might want to look into using one of the available templating mechanisms (e.g., HTML::Template) so that you can edit your HTML separate from program logic.


In reply to Re: A Matter of Style in CGI by dws
in thread A Matter of Style in CGI by Spenser

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.