[Israel.pm] checking for presence of a value in a list
Ran Eilam
ran.eilam at gmail.com
Thu Aug 30 03:39:01 PDT 2007
> > Well, you're right that List::MoreUtils is not core and List::Util is.
> > However, why is "first" preferable over "any"? I think "any" would be
> > preferable here, because we're not interested in the first item that
> > matches, just if it exists. And "any" probably short-circuits.
Yes it does, so you are, as always, right.
sub any (&@) {
my $f = shift;
return if ! @_;
for (@_) {
return 1 if $f->();
}
return 0;
}
Ran
--
Ran Eilam ran.eilam at gmail.com
More information about the Perl
mailing list