This is maybe a bit redundant if you've taken already taken heed of sauoq's sage advice, but if not, here's another completely un-biased opinion :).

Take heed of sauoq's sage advice.

Just to expand slightly on matters more 'stylistic'. sauoq's point about perltidy referred to your formatting - indentation etc. It may sound petty ("what the h*ll does it matter how *pretty* my code is so long as it works?") but a geat deal of coding is about stucture. Proper indentation, consistent brace styles and the like all help to make that structure more obvious. Forgive me if some conversion-to-html-then-txt destroyed your already-perfect indentation, but looking at the kind of redundancy etc. that I reckon you would have spotted had your code been 'easy on the eye', I doubt it.

Another thing that makes code 'ugly' and hard-to-read is the mixing up of data and code, making it difficult to find specific parts of both. Here, your data is "print" statements containing (mainly) 'static' stuff. It's much more readable to have something like....

if ($something) { print $big_long_something_response; } else { print $other_big_long_string }
rather than...
if ($something) { print "Something happened"; print "I could have defined this elsewhere in the file"; print "Or even used one of the fine templating modules..."; print "...available from a CPAN mirror near you..."; print "but instead I'm going to print 40 lines of code.."; print "and make this upcoming 'else' statement.."; print "really had to find without bracket bouncing all the time."; } else { print "you're going to have to bracket-bounce this one too.."; print "to skip what is basically a "do this or this" piece of code." +; . . }
If you organised your code like this, you'd spot a lot of duplicated text ("This code copyright Pine Tree" etc.) that could be squirreled away (in "$copyright" for instance), making your intentions more obvious to yourself and others. In addition, the code would be easier to maintain, and you'd be more likely to spot structural errors /room for improvement.

Cheers, Ben.


In reply to Re: CGI DB interface by benn
in thread CGI DB interface by Jonathan17

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.