Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: without looping, check if $var is found in @list

by imp (Priest)
on Dec 14, 2006 at 02:11 UTC ( #589719=note: print w/ replies, xml ) Need Help??


in reply to without looping, check if $var is found in @list

There are a variety of ways to check for membership in a list, but the one that is right for your situation depends on the problem you are trying to solve.

For common approaches see the faq.

Update
Perl 6 will provide the any junction, which you can play with using the Perl6::Junction module for now.

use Perl6::Junction qw/ any /; if (any(@list) eq $var) { }


Comment on Re: without looping, check if $var is found in @list
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (5)
As of 2015-08-03 23:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The oldest computer book still on my shelves (or on my digital media) is ...













    Results (59 votes), past polls