- or download this
use List::Util 'first';
my $first_index = first { test( $arr[ $_ ] ) } 0..$#arr;
- or download this
my $first_index = first { $arr[ $_ ] =~ /$pat/ } 0..$#arr;
- or download this
my $first_index = ( grep test( $arr [$_ ] ), 0..$#arr )[ 0 ];