Could also use this for

  foreach $item $key ( %hash ) {
     print "$item is indexed by $key\n";
  }

"Christopher J. Madsen" wrote:

> 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

--
Glenn
=====
There  are two kinds of people, those
who finish  what they start,  and  so
on...                 -- Robert Byrne

____________NetZero Free Internet Access and Email_________
Download Now     http://www.netzero.net/download/index.html
Request a CDROM  1-800-333-3633
___________________________________________________________

Reply via email to