Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

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

by Anonymous Monk
on Feb 15, 2000 at 01:31 UTC ( #3480=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 Anonymous Monk

Try this to search for the presence of an element in an array.
my $element = 'Whatever you are searching for' ; if (grep {$_ eq $element} @TheArray) { print "Element '$element' found!\n" ; }

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 taking refuge in the Monastery: (6)
As of 2020-10-19 22:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (207 votes). Check out past polls.

    Notices?