use strict; use warnings; use Regexp::Common qw(time); my $DATE = $RE{time}{mdy4}{-keep}; my @dates = qw( 01/02/2006 1/2/2006 11/22/2006 12/1/2006 13/1/2006 2/35/2006 1/2/06 ); for my $date (@dates) { my ($whole, $mon, $day, $year) = $date =~ $DATE; if (defined $whole) { printf "%10s => (%2s, %2s, %s) => (%02d, %02d, %d)\n", $whole, $mon, $day, $year, $mon, $day, $year, ; } else { printf "%10s => No match\n", $date; } } #### 01/02/2006 => (01, 02, 2006) => (01, 02, 2006) 1/2/2006 => ( 1, 2, 2006) => (01, 02, 2006) 11/22/2006 => (11, 22, 2006) => (11, 22, 2006) 12/1/2006 => (12, 1, 2006) => (12, 01, 2006) 13/1/2006 => No match 2/35/2006 => No match 1/2/06 => No match