When i started with perl, I was doing some CGI scripts using some sort of "readform" sub that tried to parse CGI params itself.

Eventually I found out that i could write "use CGI;" and it would do it all FOR me. That was pretty amazing to me. No more cutting and pasting of that half-asses sub.

Around the same time I learned about strict and warnings. What's this? Write two lines and it will find (some) problems with my script FOR me? Sweeet.

Generally, all of my programs looked something like this:

my $action = $cgi->param( 'action' ); if( $action eq 'show' ) { # ... } elsif( $action eq 'delete' ) { # ... } else { # ... }

After joining perlmonks, i found out about CGI::Application. It handles all of that messy if-elsif-else crap FOR me! At the same time, using HTML::Template allowed me to get rid of all of those pesky print q(...); and print << EOHEADER; statements and let my script focus on the data rather than the output.

Generally, my post can be summed up into: be lazy.

It really pays off. You get code re-use thus you have to write LESS code. Fewer, if any, cut & paste errors. Generally these modules are more robust and feature-rich than your code (because the module focusses on one single task).

Sure, no one is FORCING you to use these modules. You're welcome to write your own readform() sub as much as the next person. But... Why would you WANT to?

--
"To err is human, but to really foul things up you need a computer." --Paul Ehrlich


In reply to Re: Perlmonk's "best pratices" in the real world by LTjake
in thread Perlmonk's "best pratices" in the real world by schweini

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.