in reply to Ways to control a map() operation
last cannot be used to exit a block which returns a value such as eval {} , sub {} or do {}This is a bit ambigous. As a matter of fact, you can leave eval{}, sub{} or do{} using last. Have a look at this code:
It will print only "1". This is because the "last" will jump out of the for-loop, regardless of the surrounding sub{}, eval{} and do{}.sub foo { last; } for (1..3) { print; do { eval { foo (); }; }; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Ways to control a map() operation
by Leviathan (Scribe) on Jul 16, 2006 at 07:31 UTC | |
by betterworld (Curate) on Jul 16, 2006 at 11:13 UTC | |
by Leviathan (Scribe) on Jul 16, 2006 at 11:41 UTC | |
by betterworld (Curate) on Jul 16, 2006 at 11:56 UTC | |
by Leviathan (Scribe) on Jul 16, 2006 at 12:19 UTC | |
| |
|
Re^2: Ways to control a map() operation
by shmem (Chancellor) on Jul 16, 2006 at 12:58 UTC |