in reply to Too much SQL not enough perl
I prefer to use Set::Scalar for this type of condition.
use strict; use Set::Scalar; my @testItems = qw|a b c d e f g|; my $set = Set::Scalar->new('a', 'b', 'c'); foreach my $item (@testItems) { if($set->has($item)) { print "$item is in set\n"; } } __END__ Results: a is in set b is in set c is in set
Although I haven't looked at the performance of this package compared to methods suggested in this thread.
Hazah! I'm Employed!
|
|---|