Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^2: Ways to control a map() operation

by shmem (Chancellor)
on Jul 16, 2006 at 12:58 UTC ( [id://561563]=note: print w/replies, xml ) Need Help??


in reply to Re: Ways to control a map() operation
in thread Ways to control a map() operation

This is a bit ambigous. As a matter of fact, you can leave eval{}, sub{} or do{} using last.

This is plain wrong. please wait for my update before answering.. thanks

perl -le 'sub leave { last }; leave(1)' Can't "last" outside a loop block at -e line 1. perl -le '$foo = do { last }' Can't "last" outside a loop block at -e line 1. perl -le '$foo = eval { last if 1; 2; }; print $@ if $@; print ">$foo< +"' Can't "last" outside a loop block at -e line 1. ><
Rather, you can combine eval, sub and last in some obscure way which will look like it's right and perl didn't complain (although it does).

update: last exits the loop which is around such blocks immediately, thus works like a goto and is likely to leave a mess behind.

--shmem

_($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                              /\_¯/(q    /
----------------------------  \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2024-04-18 18:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found