chomp($value = ); if ($value =~ m#(0[1-9]|[12][0-9]|3[01])[-/.](0[1-9]|1[012])[- /.](\d\d\d\d)#) { print "date"; } else { print $value; print "not a date"; } #### se DateTime::Format::Strptime; my $dt_format = DateTime::Format::Strptime->new(pattern => "%d-%m-%Y"); sub val_date { my $dt = shift; $dt =~ s|[./]|-|g; # '.' and '/' become '-' for simplicity return $dt_format->parse_datetime($dt); } my $s = '01-02-2007'; my $dt = val_date($s); if ($dt) { print "valid date\n"; } else { print "not a date\n"; }