On Sun, Oct 10, 2010 at 3:59 AM, Shlomi Fish <shlo...@iglu.org.il> wrote: > Well, in this case, PBP recommends to use a while/continue loop: > > [code] > for (my $i = 0; $i < $n ; $i += 2) > { > print "$i\n"; > } > [/code] > > into: > > [code] > { > my $i = 0; > > while ($i < $n) > { > print "$i\n"; > } > continue > { > $i += 2; > } > } > [/code]
Can somebody please explain why the latter would be preferred to the former? Coding mostly with C#, C++, and C; The latter looks much uglier and much more error prone to me. Anyone familiar with a C-like language should be quite comfortable with a C-style for-loop. If you need $i anyway then I don't see the harm. If it's a performance concern then I would cry premature optimization.. -- Brandon McCaig <bamcc...@gmail.com> V zrna gur orfg jvgu jung V fnl. Vg qbrfa'g nyjnlf fbhaq gung jnl. Castopulence Software <http://www.castopulence.org/> <bamcc...@castopulence.org> -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/