in reply to Re^3: C-style for loop
in thread C-style for loop
I gave you a reason for preferring the Perl style for loop in general - fewer parts to go wrong. Eliminating a variable is not generally the important difference between two different for loop usages. Indeed:
for my $index (0 .. $#array) { ... }
Is generally a much better solution than:
for (my $index = 0; $index < $#array; ++$index) { ... }
because the range of the Perl loop is much easier to see and harder to get wrong.
In general we can say what sort of for loop is better - Perl for loops. '"C-style" is bad because of useless $i variable' is not the reason however.
Perl reduces RSI - it saves typing
In Section
Seekers of Perl Wisdom