ETL-Yertl
view release on metacpan or search on metacpan
lib/ETL/Yertl/Util.pm view on Meta::CPAN
#pod =sub firstidx
#pod
#pod my $i = firstidx { ... } @array;
#pod
#pod Return the index of the first item that matches the code block, or C<-1> if
#pod none match
#pod
#pod =cut
# This duplicates List::Util firstidx, but this is not included in Perl 5.10
sub firstidx(&@) {
my $code = shift;
for my $i ( 0 .. @_ ) {
local $_ = $_[ $i ];
return $i if $code->();
}
return -1;
}
1;
( run in 0.953 second using v1.01-cache-2.11-cpan-49f99fa48dc )