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

Re: [FWP] That was productive...



On Tue, 18 Jan 2000, Jeff Pinyan wrote:

> 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.

Of course... I was talking about using @array in scalar content to find
out the number of entries vs $#array+1 . 

Otherwise you are absolutely right :)

_______________________________________________________________________
Stas Bekman    mailto:sbekman@iname.com      http://www.stason.org/stas
Perl,CGI,Apache,Linux,Web,Java,PC     http://www.stason.org/stas/TULARC
perl.apache.org    modperl.sourcegarden.org   perlmonth.com    perl.org
single o-> + single o-+ = singlesheaven    http://www.singlesheaven.com


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