in reply to array looping with foreach
The following both provides the index and makes $ele an alias to the array element as if you had done for my $ele (@array):
for my $idx (0..$#array) { for my $ele ($array[$idx]) { ... } } [download]