I agree with the other posters about using something already built into Windows, but Date::Manip
also lets you do this fairly nicely:
my $now = time();
my $next = &UnixDate(&ParseDate("8am"), "%s");
$next += 24 * 60 * 60 if $next < $now;
sleep($next - $now);
parses the "8am", and UnixDate()
with the "%s
" format gives us the number we want. We jump ahead 24 hours if the time parsed is before the current time. A more correct way to do this would be to re-do the ParseDate with "tomorrow at 8am" instead of "8am", since DST could muck this up. I can't find a way to tell ParseDate to use the next future occurrence of "8am" instead of assuming "today at 8am" without messing up the pre-8am case.
ParseDate is also somewhat slow.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
| & || & |
| < || < |
| > || > |
| [ || [ |
| ] || ] ||