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

Re: [FWP] That was productive...



* Stas Bekman (sbekman@iil.intel.com) [000118 08:12]:
> > Hmm. I wonder how many ex-C now perl programmers have written...
> >    for( $i = 0; $i < $#array; $i++)
> > instead of...
> >    for( $i = 0; $i <= $#array; $i++)
> 
> The Perl idiomatic syntax is:
>     for( $i = 0; $i < @array; $i++)

No it's not.  BUt arguments about idiomacy aside,
	for ( $i = 0; $i <= $#a; $i++ )
is preferable, I think, to 
	for ( $i = 0; $i < @a; $i++ )
because it "looks" more like the more usual formulation, 
	for $i ( 0 .. $#a ) {
i.e., the start and end points are written the same way.

-- 
John Porter

"There are people who have fun studying the C++ spec for
literally seconds on end, I'm sure..."    John Vlissides


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