Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
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?
[Eily]: Discipulus well, $ for $calar makes sense, I don't know how we would explain the
[Discipulus]: i was given 20 pages of introduction to perl, in eatalian buy a guy who tech us hoou to set up a little linux network: I have to find him a give some red wine
[Discipulus]: it was 1999
[Veltro]: I started programming perl because of while(<>){ s/.../.../} One week later I was programming all kinds of different stuff.

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (9)
As of 2018-06-22 09:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?



    Results (123 votes). Check out past polls.

    Notices?