Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Answer: How to find out if X is an element in an array?

by guha (Priest)
on Nov 25, 2010 at 17:18 UTC ( #873689=categorized answer: print w/replies, xml ) Need Help??

Q&A > arrays > How to find out if X is an element in an array? - Answer contributed by guha

#!perl use strict; use warnings; use List::MoreUtils qw{ any }; my @array = qw{ A B C D E X }; if (any { $_ eq 'X'} @array) { print 'YES'; } else { print 'NO'; }

Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2020-10-19 22:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (207 votes). Check out past polls.

    Notices?