--- Michael Fowler <[EMAIL PROTECTED]> wrote:
> On Thu, Jun 28, 2001 at 02:34:31PM -0700, Paul wrote:
> > > $city = $record[3] ;
> > > for ($i = 0; $i <=  $#{ $state{$city}; $i ++  ) {  
> > 
> > Never use the
> >  for( ; ; ) { }
> > construct in Perl without a significant and compelling reason.
> > foreach is virtually always better for lots of reasons. Try:
> > 
> >   for my $i ( 0 .. $#{ $state{$city} ) {
> 
> Well, you make a good point that one should use foreach, but then you
> use it
> in almost identical way as the for loop.  If you were to use it this
> way,
> you might as well use a for loop.  The most readable and idiomatic
> way to do
> this is:
> 
>     foreach my $street (@{ $state{$city} }) {
>         ... if $street ne "MAIN";
>     }
> 
> You should try to avoid the foreach (0 .. $#array) form; that list
> has to go
> into memory somewhere, and it's just a more verbose way of saying
> foreach
> (@array).
> 
> Otherwise, that's some good advice.

lol -- my point was poorly made.
I meant that if you feel you *have* to iterate over indexes, you can
still use foreach.

Your point is apparently that you almost never need to iterate over
indexes, which is the half of the point I meant to make that I never
got around to, lol!!!!! =o)

__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/

Reply via email to