in reply to Timed Execution

a quick hack would be something like this:
do { sleep(1); } until ( (localtime(time))[2] == 11 && (localtime(time))[1] == 0 );

this snippet added to the top of your script will loop until 11:00 and continue executing your script.
note that this is just a workaround! you really should use cron or something similar if you're stuck to windows.

-- slayven

Replies are listed 'Best First'.
Re: Re: Timed Execution
by joealba (Hermit) on Nov 06, 2001 at 10:08 UTC
    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. :)
      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.
Re:{2} Timed Execution
by jeroenes (Priest) on Nov 06, 2001 at 11:42 UTC
    Just remember that when you want to run such a script in the background, you need at least a $SIG{'INT'} = 'IGNORE'. Look at perldoc perlvar and/or take a peek here, which actually is my first node at this place.