go ahead... be a heretic | |
PerlMonks |
Re^9: resetting a foreach loop!by AnomalousMonk (Archbishop) |
on Nov 18, 2017 at 20:26 UTC ( [id://1203760]=note: print w/replies, xml ) | Need Help?? |
Now that I've thought about it some more, I think the point ikegami is making is that just the fact that a behavior is commonly implemented doesn't mean it is actually specified anywhere. And in this case, the behavior of if (CONDITION) BLOCK is nowhere specified, so don't rely on it. As I've mentioned before and as you've noted, the behavior of an if-statement returning the result of evaluating CONDITION when CONDITION is false and the if-statement is the final statement executed in a subroutine is familiar and seems quite reasonable; it's not surprising that many, perhaps most, Perl implementations adopt this behavior. Whether this behavior is specified and reliable is another question, one I don't have time to pursue ATM. Other questions occur: what's returned from evaluation of a false CONDITION in a while-loop that is the last statement executed in a subroutine? (I don't dare think about what's going on with a for-loop!) Food for thought — and links for more reading. Give a man a fish: <%-{-{-{-<
In Section
Seekers of Perl Wisdom
|
|