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

What is the reason my original code will skip the last entry?

The problem is using join to join the lines using some string, which only inserts that string between elements of the array, and then using a regex that requires all entries to end on that string. In the following example, based on your original code, I'll demonstrate the problem, note how in the output, "Baz" is missing because it is not followed by "ENDOFLINE". The other problem I mentioned was that log entries that don't match the regex will be skipped (and may possibly even cause other entries to be parsed incorrectly, as this example shows):

use warnings; use strict; use Data::Dumper; $Data::Dumper::Useqq=1; my @mylog = <DATA>; my $myfixedlog = join("ENDOFLINE", @mylog); print Dumper $myfixedlog; while ($myfixedlog =~ /([A-Za-z]+)\nENDOFLINE/smg) { print Dumper $1; } __DATA__ Foo 123 Bar Quz Baz

Output:

$VAR1 = "Foo\nENDOFLINE123\nENDOFLINEBar\nENDOFLINEQuz\nENDOFLINEBaz\n +"; $VAR1 = "Foo"; $VAR1 = "ENDOFLINEBar"; $VAR1 = "Quz";