use Date::Calc qw( Date_to_Days ); if (Date_to_Days($year3,$month3,$day3) <= Date_to_Days($year1,$month1,$day1)) { print "Location: $msg_ok\n\n"; exit; } else { print "Location: $msg_badmail\n\n"; exit; } if (Date_to_Days($year1,$month1,$day1) < Date_to_Days($year2,$month2,$day2)) { print "Location: $msg_ok\n\n"; exit; } else { print "Location: $msg_badmail\n\n"; exit; }