I firmly believe that the number of accidental mistakes through changing context is far outweighed by the mistakes which are prevented through misunderstanding relative precedence. As for cargo cult programming, yeah. Anything you do can be picked up as a meme and propagated blindly. But still considering the relative frequency of errors made/prevented, I like adding the parentheses. If people are going to blindly follow habits, let them at least follow good ones.

And I consider parenthesizing for clarity to be a good practice. (Note that had kha0z followed that practice with the tie we would not be having this discussion right now...)

FWIW I am in good company with my opinion, in perlstyle adding unnecessary parentheses is listed as a "more substantive style issue". The relevant section says:

Along the same lines, just because you CAN omit parentheses in many places doesn't mean that you ought to: return print reverse sort num values %array; return print(reverse(sort num (values(%array)))); When in doubt, parenthesize. At the very least it will let some poor schmuck bounce on the % key in vi. Even if you aren't in doubt, consider the mental welfare of the person who has to maintain the code after you, and who will probably put parentheses in the wrong place.
So yes. It is possible to put parentheses in the wrong place and accidentally ruin your context. That is a mistake I only rarely see and I have never made. But I have both seen and made plenty of mistakes where parenthesizing would have prevented a mistake.

In fact the only common mistake with parentheses that I know of is being tripped up by the fact that print is a function. I consider learning that fact to be far less to ask than any significant part of the precedence table. Particularly since a messed-up print tends to be far more obvious mistake than a non-functional error check. (I try to test my error checks, but I know full well that most people do not...)

UPDATE
I agree that it is situational. If you come from C then the precedence is pretty much trivial because the table is (intentionally) the same. For people who are not from a C background or whose C is rusty... (And yes, I have seen similar code from people used to C trying out Perl.)


In reply to Re (tilly) 6: Add hash to DB_HASH file using DB_File by tilly
in thread Add hash to DB_HASH file using DB_File by kha0z

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.