I don't see why this should be an implicit counter. This (might)
cause extra work for every foreach loop in every program (depending on
how foreach is implemented).
Why not use an explicit counter instead? Something like
foreach $item $index (@array) {
print $item, " is at index ", $index, "\n";
}
(This is a syntax error in Perl5.)
This avoids problems with nested foreach loops, and makes it easy to
do the extra work only for loops that actually want it. It also
avoids adding one more hard-to-remember punctuation variable.
Also, what happens if you're not iterating over a single array?
(eg "foreach (@array, @more, qw(a b c))"). I vote for it being an
index into the meta-array you get by combining all those lists.
But, what happens when somebody does
foreach $item $index (@array) {
delete $array[$index] unless defined $item;
}
Does that work? Should it?
--
Chris Madsen http://www.trx.com [EMAIL PROTECTED]
TRX Technology Services (214) 346-4611