1     #!/usr/bin/perl
2     use strict;
3     $|=1;
4     
5     use LWP::Simple;
6     
7     my $LOGDIR = "/home/merlyn/Logs"; 
8     @ARGV = (
9              (map { "gunzip <$_|" } <$LOGDIR/error_log.*[0-9].gz>), 
10             <$LOGDIR/error_log.*[0-9]>,
11             "$LOGDIR/error_log", 
12            );
13    
14    my %seen;
15    while (<>) {
16      next unless /404 ERROR/;
17      s/^\[//;
18      s/\]\s*$//;
19      my @fields = split /\] \[/;
20      my ($time, $wanted, $ref) = @fields[0,2,4];
21      next unless $ref =~ /^http:/; # solid HTTP fetch 
22      next if $ref =~ /\?/;         # no CGI searches 
23      next if $seen{$ref}++;        # once only
24      print "[$time $wanted $ref]\n"; 
25      my $content = get $ref;
26      unless (defined $content) {
27        print "... content not available\n"; 
28        next;
29      }
30      my @stonehenge = $content =~ /(\S*stonehenge\S*)/mig; 
31      if (@stonehenge) {
32        print map "  hit: $_\n", @stonehenge;
33        print map "  mailto: $_\n", $content =~ /(\S*mailto:\S*)/mg; 
34      }
35    }