I think the answer to your question is dependent on context: Correctness usually is ...

If your writing a program that is likely to run for hours on an expensive resource, then perhaps the interesting bench-marking discussed by other posters probably counts for something. After all: if it is costing lots of $$/minute to run the program, it might be worth it to spend the $$ up front and have really efficient code from a hardware performance and resource point of view.(But if that were the case, would you be programming in Perl?)

If your writing code under the vast majority of circumstances, then the 'team' aspect is probably more important, as wading through code written for brevity, as compared to having been written for readability/maintainabilty, can be costly. Personally, I prefer code which, when read by someone other than the author, does not assume that the reader knows much about the implicit characteristics of how the code compiles or runs. It boils down to a potential trade-off between some extra hardware resources applied occasionally as compared to wetware resources applied fairly regularly. On the other hand, that does not mean that every line needs a comment either as some level of skill should be assumed to be had by the code reader/modifier. Obviously a balancing act...

In my experience, correctness is the in realm of those that think the world should reflect the way they like things to be, as compared to for example, the way I like things to be. :-) Am I correct or are they? I am of course!

The point is that if you take a look around at code written by others who appear to be better than you are and find someone whose code you like, emulate that until you have a valid reason not to. If your goal is to be correct, you are going to spend an awful lot of time defending your version of correct. Do what works for you and does not get in the way of others and you will be about as correct as your likely to ever be...

Incidentally, I like the 'my %hash = ();' just because it is so explicit. Am I correct? I doubt it...but it works for me and most others really don't give a damn that I spent and extra 5 keystrokes.... :-)


...the majority is always wrong, and always the last to know about it...
Insanity: Doing the same thing over and over again and expecting different results...

In reply to Re: Is there a difference in this declaration? by wjw
in thread Is there a difference in this declaration? by Anonymous Monk

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.