my $counter = 0; while($counter <= $#array) { #do your thing $counter++; }