in reply to (tye)RE: The Best Infinite Loop
in thread The Best Infinite Loop
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 Section
Meditations