orwherever you'd been using the punctuation versions. They have difference precedences. You must learn precedence. And a few parens seldom hurt.
print FH $data || die "Can't write to FH: $!"; # NO print FH $data or die "Can't write to FH: $!"; # YES
$a = $b or $c; # bug: this is wrong ($a = $b) or $c; # really means this $a = $b || $c; # better written this way
@info = stat($file) || die; # oops, scalar sense of stat! @info = stat($file) or die; # better, now @info gets its due
$a % 2 ? $a += 10 : $a += 2Really means this:
(($a % 2) ? ($a += 10) : $a) += 2Rather than this:
($a % 2) ? ($a += 10) : ($a += 2)
Forward to Don't Overdo `?:'
Back to Embrace && and || for Control and Values
Up to index
Copyright © 1998, Tom Christiansen
All rights reserved.