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

Re: [FWP] That was productive...



On Jan 18, Stas Bekman said:

> The Perl idiomatic syntax is:
>     for( $i = 0; $i < @array; $i++)

Well, I would hardly call that idiomatic.  That's idiomatic from a C
programmer's perspective.  Rarely, in Perl, do you need the index of an
element when iterating over an array, and if you do, you can get that
simply with

  $i = 0;
  for (@array) {
    # ...
    $i++;
  }

But again, indices aren't need all too often, when you've got the flesh
and bones element at your fingertips.

-- 

  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