in reply to Re^3: Is there a Perl variable to count iterations in a loop?
in thread Is there a Perl variable to count iterations in a loop?

But this works
my @letters = qw(alfa beta gama); for my $letter (@letters){ warn "iteration is ", scalar($0 .. !$0); } for my $letter (@letters){ warn "iteration is ", scalar($0 .. !$0); }
I think the range-operator depends on the code position, but your sub is always at the same one. *

Cheers Rolf

UPDATE: well the documentation could be clearer...
perlop

... The sequence number is reset for each range encountered ....
...in the compilation phase!!!

(*) that's why the scalar range is known as flip-flop-operator