in reply to Re: How to check whether my array contains element x
in thread How to check whether my array contains element x
You forgot to mention hashes! =)
DB<101> sub in { my ($entity, @array) = @_; my %hash; @hash{@array}=(); return exists $hash{$entity}; } DB<102> in(5,0..10) => 1 DB<103> in(42,0..10) => ""
but I wouldn't pass @array as a flat list.
Cheers Rolf
|
---|
In Section
Seekers of Perl Wisdom