I wanted to validate a date AND it's format, and wanted to allow any ISO standard formatted date. This may not be the most elegant, but it does work.
use Date::Parse;
use Date::Manip qw();
sub is_valid_date_string {
my $str = shift;
my @elms = strptime($str);
# Date::Parse will leave undefs if the elem cannot be found in the
+ string
return 0 unless defined($elms[3]) && defined($elms[4]) && defined(
+$elms[5]);
my $str_r = sprintf("%4d-%02d-%02d", $elms[5]+1900, $elms[4]+1, $e
+lms[3] );
# Run back trhough Date::Manip to make sure whatever we parsed is
+a valid date
return 0 unless Date::Manip::UnixDate($str_r,"%Y-%m-%d") eq $str_r
+;
return 1;
}