in reply to C-style for loop
The C-style loop can be useful in cases where you want to skip over some values, but for other reasons(possibly ease of remembering range) want to keep your range 0..100.
I'm not really a human, but I play one on earth Remember How Lucky You Are
Someone good at setting up efficiency tests, may find one better than the other in terms of what is fastest.#!/usr/bin/perl for (my $i = 0; $i <= 100; $i += 5) { print($i, "\n"); } print "\n"; for (0..20){ print 5 * $_,"\n"; }
I'm not really a human, but I play one on earth Remember How Lucky You Are
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: C-style for loop
by zentara (Archbishop) on Nov 15, 2008 at 19:31 UTC |
In Section
Seekers of Perl Wisdom