I say your subroutines are way too big. I almost never validate parameters to subroutines. Instead I validate the input. After that any other validation is redundant. How do I debug my subroutines? I write them small and incrementally test them as I build (I did mention your subroutines are too big).

As for the doublespeak of the “Code Purists,” this is stuff you regurgitated to get a good marks in college. “Subroutines should have only one entrance and only one exit” is part of their “goto”-less coding. They insist on using state variables, whose contents must be examined to determine what to do next, rather than making the routing explicit. But using state variables is obfuscation. When you are walking-through the code, you have to remember what state each is in and scan the code that isn’t active until you find some that is. With “goto” statements like return, last, next, redo, and die; you can skip the intervening code and get on with your walkthrough.

I never put in “end of” comments; I use Vim which automatically matches parentheses as I type. It also automatically indents every time I type ‘{’ and outdents when I type ‘}’. I can easily find the beginning of every end.


In reply to Re: A matter of style by Anonymous Monk
in thread A matter of style by Ryszard

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.