"be consistent" | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Regarding the for loop issues (and this may apply to other loop controls as well), it seems that the loop must stop on a false boolean expression. If that's the last expression in the sub, then that should be returned.
Note that under the hood, all of the loop constructs can be mapped to a single generic construct (which I suspect is what actually happens). Suppose we have this: While you may think the last thing evaluated is print "$q\n", the for actually has to check that there are no more elements in the list, perhaps making the above code equivalent to: So the last expression evaluated is not @_forlist. Which is not explicit in the code! Most of the errant behaviors documented in this thread seem to ignore this implicit expression. Perhaps the documentation could emphasize that "last expression" doesn't mean "last explicit expression". BTW, does someone have the skills to investigate the optree for examples like these? -QM In reply to Re: "last expression" quiz
by QM
|
|