Array-AllUtils
view release on metacpan or search on metacpan
lib/Array/AllUtils.pm view on Meta::CPAN
# (RT88848) Touch the caller's $a and $b, to avoid the warning of
# Name "main::a" used only once: possible typo" warning
#no strict 'refs';
#${"${pkg}::a"} = ${"${pkg}::a"};
#${"${pkg}::b"} = ${"${pkg}::b"};
goto &Exporter::import;
}
# BEGIN_BLOCK: first
sub first(&$) {
my $code = shift;
for (@{$_[0]}) {
return $_ if $code->($_);
}
undef;
}
# END_BLOCK: first
# BEGIN_BLOCK: firstidx
sub firstidx(&$) {
my $code = shift;
my $i = 0;
for (@{$_[0]}) {
return $i if $code->($_);
$i++;
}
-1;
}
# END_BLOCK: firstidx
( run in 1.001 second using v1.01-cache-2.11-cpan-49f99fa48dc )