use strict; use Time::Local; # Time::Local uses an index of 0 for the month # (as does localtime and gmtime) # Lower Limit my $year1 = 2001; my $month1 = 7; my $day1 = 6; my $hour1 = 20; my $min1 = 00; my $sec1 = 00; # Upper Limit my $year2 = 2001; my $month2 = 7; my $day2 = 6; my $hour2 = 20; my $min2 = 59; my $sec2 = 00; # Convert the lower limit into seconds my $min_time = timelocal($sec1,$min1,$hour1,$day1,$month1,$year1); # Convert the upper limit into seconds my $max_time = timelocal($sec2,$min2,$hour2,$day2,$month2,$year2); # Get the current time, in seconds my $now = time(); # If we haven't yet reached the minimum time if ($now < $min_time) { print "It's before my time!"; } # If we're past due elsif ($now > $max_time) { print "It's after my time!"; } # Otherwise, we're right on time! else { print "Ahhh, just right!"; }