in reply to better way to find list members?

This may be a little off the wall:

If all you're after is the instances of a particular number and you don't horribly care about the RE, you could try this:

sub count_instances { my $list = join ' ', shift(); my $val = shift; return $list =~ /\b$val\b/; }

It's quick and to the point but it does the very same RE slow-down that japhy warned about, but it doesn't use grep. This is still slower probably, but it will return the number of matches found and 0 if the number isn't there. If i got this wrong could someone please point out errors?

Update Sidenote:
If you just wanted to find out if the value is there, you could just use index($val, $list) which will return -1 if not found and the first index if it is found; assuming you use the string representation.


jynx

PS If you plan on passing an array to a function you should probably pass a reference, which makes the code more like:

sub count_instances { my $list = shift; my $val = shift; $list = join ' ', @{ $list }; return $list =~ /\b$val\b/; }