in reply to Scheduling with Perl?

use Time::Local; use strict; sub waityourturn { my $now = time; my $twohours = 60*60*2; my $onehour = 60*60; my ($sec,$min,$hour,$mday,$mon,$year) = localtime($twohours+$now); if ($hour % 2 == 0) { # if hour is even, let's just add one hour ($sec,$min,$hour,$mday,$mon,$year) = localtime($onehour+$now); } $sec = 0; $min = 30; my $target_time = timelocal($sec,$min,$hour,$mday,$mon,$year); my $naptime = $target_time - time; print "I am going to sleep $naptime seconds until ", scalar(localtime($target_time)), "\n"; sleep($naptime); }