[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] That was productive...



> :   $i = 0;
> :   for (@array) {
> :     # ...
> :     $i++;
> :   }
> 
> Perhaps slightly less problematic:
> 
>     $i = 0;
>     for (@array) {
>         ...;
>     }
>     continue {
>         $i++;
>     }

I pondered writing that in the continue { } block, but I decided not to.

Sometimes, I use something like:

  for ($i = 0; local $_ = $array[$i], $i < @array; $i++) {
    ...
  }

to kill two birds with one stone.  But I rarely need array indices.

-- 

  MIDN 4/C PINYAN, USNR, NROTCURPI     http://www.pobox.com/~japhy/
  jeff pinyan: japhy@pobox.com     perl stuff: japhy+perl@pobox.com
  "The Art of Perl"               http://www.pobox.com/~japhy/book/      
  CPAN ID: PINYAN  http://www.perl.com/CPAN/authors/id/P/PI/PINYAN/
  PerlMonth - An Online Perl Magazine     http://www.perlmonth.com/


==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe