#!/usr/bin/perl use strict; use warnings; use Date::Parse qw(str2time); my %log; if (!$ARGV[0]) { die("Must supply a logfile to sort"); } open(LOG, $ARGV[0]); while() { my ($a, $b, $c, $date, $tz, $e) = split / /, $_; $date =~ s/^\[//; $tz =~ s/\]$//; $tz = int($tz) / 100; my $epoch = str2time($date, $tz); if (!defined(@{$log{$epoch}})) { @{$log{$epoch}} = (); } $log{$epoch}[$#{$log{$epoch}} + 1] = $_; } my @epochs = sort {$a <=> $b} keys %log; foreach my $epoch (@epochs) { foreach my $line (@{$log{$epoch}}) { print "$line"; } }