rlb3 has asked for the wisdom of the Perl Monks concerning the following question:
Anything you have to offer would be great. rlb3#!/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,<FILE>); } @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); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Sorting apache log files
by joealba (Hermit) on Sep 30, 2002 at 21:22 UTC | |
|
Re: Sorting apache log files
by dws (Chancellor) on Sep 30, 2002 at 20:28 UTC | |
by diotalevi (Canon) on Sep 30, 2002 at 21:14 UTC | |
by ehdonhon (Curate) on Sep 30, 2002 at 22:45 UTC | |
|
Re: Sorting apache log files
by PodMaster (Abbot) on Oct 01, 2002 at 00:42 UTC | |
by rlb3 (Deacon) on Oct 01, 2002 at 05:46 UTC |