in reply to Re^2: DateTime::Format::Flexible; for Log Parse with multiple formatted lines
in thread DateTime::Format::Flexible; for Log Parse with multiple formatted lines
Hi, I was referring to the sample data lines you included, which are not in code tags and thus are mangled. This had prevented me from trying to solve your problem ...
An SSCCE here would, as I said, contain only enough code and data to demonstrate your issue. Using the __DATA__ section in a file allows you to include data and code in the same file but keep them separate. Perfect for an SSCCE. For example:
Output:use strict; use warnings; use feature 'say'; use DateTime::Format::Flexible; use Test::More tests => 2; my $wanted = '2017-02-20 09:30:53'; for my $string ( <DATA> ) { chomp $string; my $dt = DateTime::Format::Flexible->parse_datetime( $string ); is( $dt->strftime('%F %T'), $wanted, "with >$string<" ); } __DATA__ Mon Feb 20 09:30:53 2017 2017-02-20T09:30:53.177000
(edit: updated example with OP's data)1..2 ok 1 - with >Mon Feb 20 09:30:53 2017< ok 2 - with >2017-02-20T09:30:53.177000<
Hope this helps!
|
|---|