Beefy Boxes and Bandwidth Generously Provided by pair Networks
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??


in reply to Re^8: resetting a foreach loop!
in thread resetting a foreach loop!

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:  <%-{-{-{-<

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1203760]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (2)
As of 2024-04-26 04:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found