in reply to Finding values position in array

From first_index in List::MoreUtils:
Returns the index of the first element in LIST for which the criterion in BLOCK is true. Sets $_ for each item in LIST in turn:
Update:
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;