Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^2: How to check whether my array contains element x

by Your Mother (Chancellor)
on Jan 17, 2013 at 20:26 UTC ( #1013883=note: print w/ replies, xml ) Need Help??


in reply to Re: How to check whether my array contains element x
in thread How to check whether my array contains element x

What they already said except that since you're not actually using regex, you shouldn't use regex. This will be faster and have fewer caveats (I inverted the statement as a matter of stylistic preference, not because it's necessary)–

print "Found it.\n" if grep { $_ eq $value } @array;


Comment on Re^2: How to check whether my array contains element x
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1013883]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2015-07-05 18:26 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 (67 votes), past polls