Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
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 about the Monastery: (13)
As of 2015-07-01 18:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (16 votes), past polls