On Thu, Mar 8, 2012 at 11:58 PM, Roman M. Parparov <[email protected]>wrote:
> On 2/25/12 3:46 AM, sawyer x wrote: > > On Fri, Feb 24, 2012 at 5:55 PM, Roman M. Parparov <[email protected] > > <mailto:[email protected]>> wrote: > > > > And if you need steps different than one? Non-linear? :) > > > > > > Relatively rare. Most uses are for single step. > > If you happen to fall on a case using other steps, you would know to > ignore my > > warning of C-style for loops. :) > > > > > Recently I found another use: > If I need the index value after the loop. :) > Nope! :) Writing a C-style for() loop does not give you the index value if you define it using my(). If you write: for ( my $i = 0; $i < 10; $i++ ) {...} you will not be able to access $i afterwards, since it will only exist in the scope of the for(). Same as with range-style for() loop. No reason not to move on to a more readable (and in calculated instances even FASTER) range-style for() loop instead. :)
_______________________________________________ Perl mailing list [email protected] http://mail.perl.org.il/mailman/listinfo/perl
