in reply to need help on declaring variables
is returning undef because the input string in $1 is in an incorrect format. Either change the declaration of Strp likemy $dt = $Strp->parse_datetime($1);
to throw an error in that case or check for it in your code by replacing the line starting 'my $dt...' withmy $Strp = new DateTime::Format::Strptime(pattern => '%Y-%b-%d %T' +, on_error => 'croak');
unless (my $dt = $Strp->parse_datetime($1)) { warn "invalid datetime: $1"; next; }
|
|---|