G
Graham Stow
The following script (or something much like it) runs continuously on a web
server and does something when the date changes (i.e. at the bewitching
hour). Problem is, it does it 2 or 3 times, when I want it to do it only
once. Any ideas anyone?
$start_date = "2008-09-20"; # this 'date' (string) will never change
and could be anything
&get_todays_date;
$date = $todays_date;
while ($date ne $start_date) { # the 2 'dates' will never equate, so
this script runs forever
&get_todays_date;
if ($date ne $todays_date) {
$date= $todays_date;
do something.....
}
}
sub get_todays_date {
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
$year=$year+1900;
$mon=$mon+1;
if (length($mon) eq 1) {
$mon = "0"."$mon";
}
if (length($mday) eq 1) {
$mday = "0"."$mday";
}
$todays_date = "$year"."-"."$mon"."-"."$mday";
}
server and does something when the date changes (i.e. at the bewitching
hour). Problem is, it does it 2 or 3 times, when I want it to do it only
once. Any ideas anyone?
$start_date = "2008-09-20"; # this 'date' (string) will never change
and could be anything
&get_todays_date;
$date = $todays_date;
while ($date ne $start_date) { # the 2 'dates' will never equate, so
this script runs forever
&get_todays_date;
if ($date ne $todays_date) {
$date= $todays_date;
do something.....
}
}
sub get_todays_date {
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
$year=$year+1900;
$mon=$mon+1;
if (length($mon) eq 1) {
$mon = "0"."$mon";
}
if (length($mday) eq 1) {
$mday = "0"."$mday";
}
$todays_date = "$year"."-"."$mon"."-"."$mday";
}