"BVA" == Bruce Van Allen <[EMAIL PROTECTED]> writes:

>> I think you meant $t - time;

BVA> No, I'm fairly sure it works best the way Ilmari wrote it...

I ran his code. It didn't work. I looked at it, switched it to time - $t, 
it worked.

BVA> How about:

   use Time::HiRes qw(time sleep);   # optional, for subsecond precision
   my $step       = 0.1; # ten iterations per second
   my $max_delay  = 5.0;        # trigger for reset

   my $t = time;
   while (1) {
       # do stuff...
   } continue {
       $t += $step;                  # watch out for rounding errors!
       my $delay = time - $t;
       $delay > $max_delay and &reset; # exit loop to reset
       $delay > 0 and sleep $delay
   }

That has side-effects and I don't think it does the same thing.

j.

Reply via email to