http://www.perlmonks.org?node_id=633981

Considering what else is provided by perl, (for example the $. variable), I have always felt the lack of a special variable (call it $LOOPCOUNTER), which starts from 0, and counts the number of times the innermost while, for, etc... has run. There would only be one such variable, so you could only use it in the innermost loop. Any loop would reset it to zero when starting, and increment it at each iteration.

With which you could write:

print "$LOOPCOUNTER $_\n" for @x;
instead of the painful,
print "$_ $x[$_]\n" for 0..@x-1;

In the example above, there doesn't seem to be much of an advantage, but in other situations, it would not only be handy, but much more legible, for example

print "$LOOPCOUNTER $_\n" for keys %$LoH->[$count];
is a lot nicer than
print "$_ keys %LoH->[$count]{$_}\n" for 0..(keys %LoH->[$count])-1;
or
my $count = 0; print $count++ . " $_\n" for keys %LoH->[$count];

Obviously there is an efficiency hit of having an increment for every loop iteration whether you want it or not. On the other hand, very often the counter is desirable, and having a dedicated counter might be more efficient than a lexical my variable that is often used in its place.

This is my first meditation, so please be gentle, in case this is a stupid idea.