for my $i (0 .. $#array) { next unless $array[$i] == 7; say "The index is $i"; }