in reply to Accessing (deleting) array elements in a hash of arrays
is better written asmy $i = 0; for my $ele (@array) { ... $i++; }
for my $i (0..$#array) { my $ele = $array[$i]; ... }
It's much more readable, and it's not broken by the use of next. (And you don't have to worry about putting the $i=0 in the wrong place like you did.)
The downside is that $ele is no longer an alias. Just use $array[$i] directly if you need to modify the original array. Just can use $array[$i] directly, period.
|
|---|