use List::MoreUtils qw/first_index/; my @array = ( 6, 5, 4, 3, 2, 1 ); my $first_4_idx = first_index { $_ == 4 } @array; print $first_4_idx;