in reply to Re: $[ is under respected.
in thread $[ is under respected.
BTW, you've got the first idiom wrong. It is: for (my $i = 0; $i < @array; $i++) { ... }
No, the correct idiom is usually
for my $elt (@array) { ... }or, in those rare cases where you really do need an index into the array, it becomes
for my $i (0 .. $#array) { ... }C-style three-clause for loops have been deemed unperlish, are deprecated, and have been removed from the core language in Perl6. If you really need the ability to manipulate the loop variable from within the loop, beyond what next and last provide, then use a while loop, but in general it's best to avoid that if possible. (Avoid using while loops in that way, I mean, not avoid using them at all.)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: $[ is under respected.
by duff (Parson) on Aug 04, 2005 at 01:18 UTC |