#!/home/sburke/bin/perl
#Time-stamp: "2005-08-19 01:26:01 ADT"

# desc{   List the most recent hits in your httpd access log.   }
#         Handy for putting in one's login file or something.

use strict;
my $in = $ARGV[0] || "$ENV{'HOME'}/logs/interglacial_access.log";
open IN, "<$in" or die $in;
seek(IN, -0x1000, 2) or die "Couldn't seek in $in";
my @lines = reverse <IN>;
pop @lines;
splice @lines, 20;
for(reverse @lines) {
  print
   "\e[1m$1\e[0m",
   $3 eq '-' ? () : "  $3",
   $2 eq '-' ? () : "  \e[7m$2\e[0m",
   "\n",
   if m{^\S+ \S+ \S+ \[.*?\] "GET (\S+) HTTP/1\.\d" [23]\d\d \S+ "(.*?)" "(.*?)"$}
}
__END__
