in reply to Re: foreach to for
in thread foreach to for

Word of advice, pick "for" or "foreach" and use one. Minor nit, but they're interchangable, and switching back and forth tends to make it less readable for me.
Well, for me, I tend to use for for C-style loops (your first example) and foreach for the aliasing loops (your second example).

I do believe a lot of people adhere to the same concept.

Replies are listed 'Best First'.
Re^3: foreach to for
by dsheroh (Monsignor) on Jun 19, 2006 at 15:15 UTC
    And, for yet another way to do it, I follow the same pattern of for for indexing and foreach for aliasing, but I build indexing loops as
    for my $i (0..$#arr) { do_whatever(); }
    instead of doing it C-style (unless I need a more complex index transition than the usual $i++).