I am just curious which methods people use for this very common problem and which is the most popular
Generally I'll just use a
grep and double negation e.g
my @array = qw/ a list of words /;
print "yep, it's there"
if !!grep { $_ eq "of" } @array;
__output__
yep, it's there
Nice and efficient in newer versions of perl (5.6.1+ ?) as it won't build a list IRC. Even quicker would be a simple regex
my @array = qw/ a list of words /;
print "yep, it's there"
if "of" =~ /\b (?: ${\join('|', @array) }) \b/x;
__output__
yep, it's there
It's not quicker on it's own (list size etc will effect performance) but if you prebuild the word list it should be quicker than
grepping every time.
HTH
_________
broquaint