in reply to Re: Timed Execution
in thread Timed Execution

Cool, but that'll only work once, and it'll waste LOTS of cpu cycles. How about this:
while (1) { sleep(50); # If it's a windows box, give yourself a little extra time. Trust me. + my ($min, $hour) = (localtime(time))[1,2]; if ($hour == 11 && $min == 0) { # Do your 11:00 stuff } }
Note that cron is the right answer. We're just having some fun. :)

Replies are listed 'Best First'.
Re: Re: Re: Timed Execution
by slayven (Pilgrim) on Nov 06, 2001 at 10:28 UTC
    actually, i've chosen sleep(1) to match 11:00:00 :)
    you're right, it will waste lots of cpu cycles, but i've been playing with idletime a while ago, because 1 second was way to much to wait for that application. i found that on my cpu (it was an AMD K6-2 300) 0.1 second was the time, that doesn't hurt the cpu at all (select(undef, undef, undef, 0.1)).
    since then i'm rather unconscionable using sleep ;)

    -- slayven
      I don't know about the Windows scheduler, but I've had Unix applications doing similar loops using usleep()'s of 100 ms. You can run 200 of those without any significant processor utilisation.