for my $i (0..$#array) { for my $e ($array[$i]) { print("Element $e was found at index $i\n"); } }