Thank you everyone for the help so far. Unfortunately, it's not working properly. Here is my code now:
my $log = $provoutfile; print "Now Processing $log....\n"; open LOG, "$log" or die "LOG $log: $!\n"; $linecnt = 0; while (<LOG>) { chomp $_; $linecnt++; my @sortedlines = map { $_->[0] } sort { $a->[1] <=> $b->[1] } map { [$_, Time::Piece->strptime($_, '%a %b %d %H:%M:%S %Y')-> +epoch ] } @lines; $line = ""; $linecnt = 0; }
It doesn't fail or error or anything... it just doesn't sort properly. When I grep TIMESTAMP out of my output file, the last dozen-ish lines look like this:
TIMESTAMP=Fri Nov 2 16:33:18 2018 TIMESTAMP=Fri Nov 2 17:26:35 2018 TIMESTAMP=Fri Nov 2 17:26:35 2018 TIMESTAMP=Fri Nov 2 17:27:33 2018 TIMESTAMP=Fri Nov 2 17:27:33 2018 TIMESTAMP=Thu Oct 18 18:29:15 2018 TIMESTAMP=Thu Oct 18 18:29:15 2018 TIMESTAMP=Thu Oct 18 18:29:27 2018 TIMESTAMP=Thu Oct 18 18:29:27 2018 TIMESTAMP=Thu Oct 18 19:06:32 2018 TIMESTAMP=Thu Oct 18 19:06:32 2018
Maybe it's because each individual log entry is broken up by newlines?

In reply to Re: Merge 2 or more logs, sort by date & time by ImJustAFriend
in thread Merge 2 or more logs, sort by date & time by ImJustAFriend

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.