in reply to getting iteration number inside iteration loop
for my $i ( 0 .. $#array ) { print "$i: $array[$i]\n"; } [download]
Note that a for/foreach loop that loops over x..y is very effecient. x..y doesn't get flattened into a list as it would elsewhere.