I'm not sure, but pg's comment in the referenced thread talks about how semantically a sub is a block in the scope of where it was called (with differences of course, such as not seeing lexicals of the containing scope). Since next just looks up the scope change for the nearest encasing block, which in this case is the foreach.
I don't really know how to explain the quoted documentation though. I just edited your function to include a return statement, and it still worked the same way.In reply to Re: Exiting subroutine via next
by geekphilosopher
in thread Exiting subroutine via next
by InfiniteLoop
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |