in reply to Re: Re: Converting MySQL datetime values to DateTime objects (regex)
in thread Converting MySQL datetime values to DateTime objects

my $when = '2003-07-14 21:39:26.357'; my ( $yr, $mo, $day, $hr, $min, $sec ) = ( $when =~ /(\d{4})(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)/ );
You have to match all of the punctuation in your source string. E.g., to match
my $when = '2003-07';
you would use
my ($yr,$mo) = $when =~ /^(\d\d\d\d)-(\d\d)/; ^
Fixing the complete regex is a variation on this theme.