Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

The Best Infinite Loop

by zdog (Priest)
on Oct 17, 2000 at 02:21 UTC ( #37048=perlmeditation: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    #!/usr/bin/perl -w
    
    ...
        'for'   => sub { $_ = 0; for   (;;)  { $_++; last if ($_ == 1000);
    + } },
        'block' => sub { $_ = 0;             { $_++; redo if ($_ < 1000); 
    + } }
    });
    
  2. or download this
    Benchmark: timing 10000 iterations of block, for, while...
         block:  8 wallclock secs ( 8.13 usr +  0.00 sys =  8.13 CPU)
    ...
         block: 66 wallclock secs (65.01 usr +  0.00 sys = 65.01 CPU)
           for: 63 wallclock secs (63.18 usr +  0.00 sys = 63.18 CPU)
         while: 64 wallclock secs (64.20 usr +  0.00 sys = 64.20 CPU)  
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlmeditation [id://37048]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2014-07-26 17:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (178 votes), past polls