use strict; use Date::Calc qw(check_date); ## my ($month, $day, $year) = (2, 29, 2036); ## valid my ($month, $day, $year) = (2, 29, 2037); ## invalid, will set to defaults ## You could use dynamic date values instead my ($def_month, $def_day, $def_year) = (2, 7, 2002); if (not check_date ($year, $month, $day)) { print "Invalid date was entered ($month/$day/$year)! ", "Default date will be used instead.\n"; ($month, $day, $year) = ($def_month, $def_day, $def_year); } print "Using date: $month/$day/$year\n";