XP is just a number | |
PerlMonks |
Re: Possible precedence issue with control flow operatorby LanX (Saint) |
on Jan 13, 2020 at 17:11 UTC ( [id://11111361]=note: print w/replies, xml ) | Need Help?? |
It's not clear to me what you really wanted. When in trouble with perlop precedence always use parentheses.
The 1. variant> return something() or croak "something didn't work"; equals
But doesn't make much sense, because the or-branch is never reached. A "normal" return almost never fails, and if return fails, the program dies right away:
(update: one might argue that the former shouldn't even compile, but there are probably use-cases in combination with do FILE )
The 2. variant> return something() || croak "something didn't work"; equals
which looks a bit strange but is somehow possible. still Carp::croak() means to die
so returning the value of croak doesn't really make sense either.
updateThe latter means mixing two very different control flows in one line ... irk. In the spirit of PBP : "make control flows immediately clear!", mixing two is quite confusing for the reader.
Cheers Rolf
In Section
Seekers of Perl Wisdom
|
|