So I tried it (with Deparse)...
while () { $_++; last if $_ == 1000; } while (1) { $_++; last if $_ == 1000; } for (;;) { $_++; last if $_ == 1000; }
perl -MO=Deparse test.pl
for (;;) { ++$_; last if $_ == 1000; } for (;;) { ++$_; last if $_ == 1000; } for (;;) { ++$_; last if $_ == 1000; } test.pl syntax OK
So they should be all the same speed. I'm with tye on this one - I'll be sticking with with while(1) since I think it looks nicer.
Have fun,
In reply to RE: (tye)RE: The Best Infinite Loop
by rdw
in thread The Best Infinite Loop
by zdog
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |