Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
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 exploiting the Monastery: (5)
As of 2014-12-27 10:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (177 votes), past polls