in reply to Merge 2 or more logs, sort by date & time

You can use Time::Piece or DateTime::Format::Strptime to parse the dates into an object (the advantage of DateTime being that it has better time zone support). If the files are small enough to fit into memory, you can use sort and a Schwartzian transform to sort them.

use warnings; use strict; use Time::Piece; use List::Util qw/shuffle/; my @input = shuffle( "Wed Oct 5 04:08:28 2018", "Fri Nov 2 14:11:28 2018", "Tue Oct 16 17:10:00 2018", "Fri Nov 2 14:11:03 2018", ); my @output = map { $_->[0] } sort { $a->[1] <=> $b->[1] } map { [$_, Time::Piece->strptime($_, '%a %b %d %H:%M:%S %Y') ->epoch ] } @input; print "$_\n" for @output; __END__ Wed Oct 5 04:08:28 2018 Tue Oct 16 17:10:00 2018 Fri Nov 2 14:11:03 2018 Fri Nov 2 14:11:28 2018