#!/usr/bin/perl -w use strict; use POSIX qw(setlocale strftime LC_ALL); require POSIX::strptime; setlocale(LC_ALL, "C"); my (@time, $dir, $file); while (<>) { @_ = (); while ($_ ne "") { if ($_ =~ /^\[/) { $_ =~ s/^\[([^"]*)\] ?//; push(@_, $1); } elsif ($_ =~ /^"/) { $_ =~ s/^"([^"]*)" ?//; push(@_, $1); } else { $_ =~ s/^([^ ]*) ?//; push(@_, $1); } } @time = POSIX::strptime($_[3], "%d/%b/%Y:%H:%M:%S"); splice(@time, -2); $dir = ($_[4] =~ /^GET/) ? "o" : "i"; ($file = $_[4]) =~ s/^\S+ ([^ ]*) \S+/$1/; if (defined($dir) && scalar(@_) == 10 && $_[5] eq "200" && $_[6] ne "-") { printf "%s %s %s %s %s b _ %s a @ apache 0 * c\n", strftime("%a %b %e %X %Y", @time), $_[6], $_[0], $_[6], $file, $dir; } }