Yes, there is a bug and you should file a bug. Be sure to CC the author because not all CPAN authors look at their RT queue.
The issue is from this line in the source:
It assumes that $target will be true - which rules out '', "0", 0, etc. That sub would probably be better written as:my $target = shift or Carp::croak "No target in member/2 ";
sub member { my ($target, @list) = @_; Carp::croak "No target in member/2 " if ! @list; if (defined $target) { for (0 .. $#list) { return $_ if $list[$_] eq $target; } return $NEG; } else { for (0 .. $#item) { return $_ if ! defined $item[$_]; } return $NEG; } }
It would also be nice if the documentation explicitly reminded the user that since it returns the index (first item = 0), member() should not be used as a boolean.
With regards to your original question - see Getting Matching Items From An Array.
Cheers - L~R
In reply to Re: sub fails second time called
by Limbic~Region
in thread sub fails second time called
by jdagius
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |