Re: RFC 120 (v2) Implicit counter in for statements, possibly $#.

[email protected] (Ken Fox) Sat, 19 Aug 2000 09:23:03 -0400
Newsgroups perl.perl6.language.flow
Organization None Apparent
Message-ID <[email protected]>
"Christopher J. Madsen" wrote:
>   foreach $item $index (@array) {
>         print $item, " is at index ", $index, "\n";
>   }

That's useful syntax, but I'd rather it mean stepping
pair-wise through @array. Then we could scan through a hash
with

  foreach $key $value (%hash) { ... }

(Hashes are flattened in array context.)

Somebody proposed a trailing index instead:

  foreach $value (@array) $index { ... }

That's short and simple and doesn't conflict. The proposal
for using each(), keys() and values() on arrays was nice too.

IMHO, since all of these things make sense and work together
nicely, I'd like to have them all.

- Ken