check time schdeule with Perl: checktime.pl
Thursday, October 7, 2010 4:37:34 PM
use Date::Calc qw(Day_of_Week);
open CONFIG, "schedule.ini" or die "open schedule.ini fail: $!";
while (<CONFIG>) {
chomp; # no new line
s/#.*//; # no comments
s/^\s+//; # no loading white
s/\s+$//; # no trailing white
next unless length; # anything left?
my ($sdow,$stime,$etime) = split(/,/,$_,3);
my ($shour,$smin) = split(/:/,$stime,2);
my ($ehour,$emin) = split(/:/,$etime,2);
# get localtime via perl function
($sec,$min,$hour,$day,$mon,$year)=localtime(time);
$mon++;
$year+=1900;
$dow = Day_of_Week($year,$mon,$day);
if ($sdow == $dow and $hour == $shour and $min == $smin) {
print "INSERTNOW";}
if ($sdow == $dow and $hour == $ehour and $min == $emin) {
print "INSERTEND";}
}
# Format of schedule.ini
# Day_of_week,Start_time,End_time. Sunday is 7.
# 7,11:20,11:22
open CONFIG, "schedule.ini" or die "open schedule.ini fail: $!";
while (<CONFIG>) {
chomp; # no new line
s/#.*//; # no comments
s/^\s+//; # no loading white
s/\s+$//; # no trailing white
next unless length; # anything left?
my ($sdow,$stime,$etime) = split(/,/,$_,3);
my ($shour,$smin) = split(/:/,$stime,2);
my ($ehour,$emin) = split(/:/,$etime,2);
# get localtime via perl function
($sec,$min,$hour,$day,$mon,$year)=localtime(time);
$mon++;
$year+=1900;
$dow = Day_of_Week($year,$mon,$day);
if ($sdow == $dow and $hour == $shour and $min == $smin) {
print "INSERTNOW";}
if ($sdow == $dow and $hour == $ehour and $min == $emin) {
print "INSERTEND";}
}
# Format of schedule.ini
# Day_of_week,Start_time,End_time. Sunday is 7.
# 7,11:20,11:22






