Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^2: "return" to break out of a loop

by mscharrer (Hermit)
on May 13, 2008 at 14:56 UTC ( [id://686286]=note: print w/replies, xml ) Need Help??


in reply to Re: "return" to break out of a loop
in thread "return" to break out of a loop

Very short but not very efficient because the implicit loop is not aborted at the first successful match. Because grep is returning the number of successful matches in scalar context all list elements are getting checked.
More efficient would be:
use List::MoreUtils; return 1 if any { $check_type eq $_ } @$enums;

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (7)
As of 2024-04-23 21:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found