i have one problem...my script cannot compare the local time with the time that user give.here is my coding:
#!/usr/local/bin/perl
$time = 0;
open(FILE,'readme.txt')||die$!;
$realtime = <FILE>;
while (defined($realtime != $time) ) {
open(FILE,'readme.txt')||die$!;
$realtime = <FILE>;
($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime(time + (3600*$timeoffset));
@days = qw(Sunday Monday Tuesday Wednesday Thursday Friday Saturday);
@months = qw(1 2 3 4 5 6 7 8 9 10 11 12) ;
$year = $year + 1900;
$time= "$mday/$months[$mon]/$year";
print "$time\n";
if ($realtime eq $time) {
print " this is the time....running schedule\n";
open(HANDLE,'config.dat')||die$!;
$data = <HANDLE>;
$mday = $mday + $data;
if ( $mday > 365) {
$year = ($data / 365) + $year;
$mday = $mday - $data;
}
elsif ($mday > 31) {
while ( $mday > 31) {
$mday = $mday - 31;
$months[$mon] = $months[$mon] + 1;
if ($months[$mon] > 12 ) {
$months[$mon] = $months[$mon] - 12;
$year = $year + 1;
}
}
}
$realtime = "$mday/$months[$mon]/$year";
open(FILE,'>readme.txt')||die$!;
print "$realtime\n";
print FILE "$mday/$months[$mon]/$year";
close FILE;
exit;
}
else {
print "this is not the time to run any program\n";
open(FILE,'readme.txt')||die$!;
$data = <FILE>;
print "the next program will be run on ";
print "$data\n";
sleep(10);
}
}
could someone tell me what is wrong with this coding....