in reply to Re^2: "open" Best Practices
in thread "open" Best Practices
I always use the low precedence and and or operators for flow of control, for example preferring:
to the equivalent:open(my $fh, '<', $file) or die "error opening '$file': $!";
open(my $fh, '<', $file) || die "error opening '$file': $!";
while always using && and || inside logical expressions, for example preferring:
to the equivalent:if ($x > 5 || $y < 10) ...
if ($x > 5 or $y < 10) ...
When this style is followed consistently, I find the code easier to read and understand at a glance.
See also Perl Best Practices, Chapter 4, "Values and Expressions", "Don't mix high- and low-precedence booleans" item.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: "open" Best Practices
by haukex (Archbishop) on Jul 13, 2019 at 09:59 UTC | |
by hippo (Archbishop) on Jul 13, 2019 at 10:25 UTC | |
by Anonymous Monk on Jul 13, 2019 at 22:04 UTC |