#!/usr/bin/perl -w use Date::Calc qw|Date_to_Time Decode_Month|; foreach $file (@ARGV) { die("This is not a file: $!") unless (-f $file); open(FILE, $file); push(@logs,); } @sorted= map {$_->[0]} sort {$a->[1] <=> $b->[1]} map{ chomp; my $stamp = get_timestamp($_); [$_,$stamp] } @logs; foreach (@sorted) { print "$_\n"; } sub get_timestamp { my $line = shift; $line =~ /\[(.*) -\d+\]/; my $tempdate = $1; my ($day,$mon,$year,$hour,$min,$sec) = $tempdate =~ /(\d+)\/(\w+)\/(\d+):(\d+):(\d+):(\d+)/; $mon = Decode_Month($mon); my $stamp = Date_to_Time($year,$mon,$day,$hour,$min,$sec); }