Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
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) { }

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 contemplating the Monastery: (5)
As of 2016-06-25 14:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My preferred method of making French fries (chips) is in a ...











    Results (326 votes). Check out past polls.