use warnings; use strict; use List::MoreUtils qw(firstidx); my @array = (2,4,7,5,8); printf "item with index %i in list is 7\n", firstidx { $_ == 7 } @array; __END__ item with index 2 in list is 7