![]() |
|
Problems? Is your data what you think it is? | |
PerlMonks |
for loop syntax differenceby sir_com (Acolyte) |
on Aug 28, 2009 at 13:47 UTC ( #791905=perlquestion: print w/replies, xml ) | Need Help?? |
sir_com has asked for the wisdom of the Perl Monks concerning the following question:
Hi Monks,
going through some site or in some post in perlmonk site, I saw that there is a difference in the for loop syntax. They say that for $i (1..10) is much efficient than for($i=0;$i<10;$i++). For example the below code for $i (1..10) { print "HI\n"; } is efficient than for($i=0;$i<10;$i++) { print "HI\n"; }. I don't understand where does the efficiency part coming here, cause in both the cases the "print" statement going to execute for 10 or n times. Then how does the first "for" syntax is efficient? Can somone please explain? thanks, sir_com
Back to
Seekers of Perl Wisdom
|
|