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
    C-style three-clause for loops have been deemed unperlish, are deprecated, and have been removed from the core language in Perl6.

    The C-style for loop hasn't been removed from perl6, it's just been renamed:

    loop my $i = 0; $i < $n; $i++ { ... }
    See S04

    And the C-style for loop has hardly been deemed "unperlish". If anything, it's unperlish for this particular purpose (iterating over an array index). It's certainly useful in other situations (though, in perl6, many of those situations are satisfied by other, newer language features)