my $first_index = ( grep test( $arr [$_ ] ), 0..$#arr )[ 0 ];