Is there any reasoning to not always use parentheses instead?Yes, clarity and readability.
While I certainly do not endorse memorising the precedence table, I feel non-casual programmers should know the precedence of very commonly used operators. To illustrate, if you follow the "always use parentheses" rule, you'd be obliged to write:
which I feel is borderline obscene. This is surely more clearly written, without the clutter of parentheses, simply as:( my $x ) = ( $y + 42 );
BTW, I would similarly object to parentheses here in C or in any language where assignment is an operator.my $x = $y + 42;
In Perl, I place the ultra low precedence and and or operators in the same category as the = operator, at least for non-novice Perl programmers. Being very low precedence makes them especially well-suited to flow of control, and I agree with Conway that reserving them exclusively for that purpose, for example:
or:open(my $fh, '<', $file) or die "error opening '$file': $!";
is idiomatic Perl and makes the code clearer and more enjoyable to read.$meaning == 42 or next;
In reply to Re^3: Please critique this script -- Read emails and write URLs into bookmarks
by eyepopslikeamosquito
in thread Please critique this script -- Read emails and write URLs into bookmarks
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |