for (my $i=0;$i<@array;$i++) { $array[$i] = 3; # dummy value # do your stuff, $i being the counter }