#!/usr/bin/perl -w use strict; use CGI qw(:standard); my $domain; &get_domain; &do_log if defined ($domain = param('Domain')); sub get_domain { my $title; if ($domain) {$title = "access log for domain $domain"} else {$title = 'access log: select domain'} print header, start_html(-title=>'access log: select domain'), startform( -method=>'POST', -action=>'access.pl', ), hr, 'Enter Domain Name: ', textfield('Domain'), br,br, submit, endform, hr, end_html; } sub do_log { my $file = '/home/htdocs/logs/access_log'; # put your log file +name and path here my @ignores = ( # suppress log entries that match any of these: '^62\.253\.128\.5', 'Scooter_trk', 'css HTTP', 'bmp HTTP', 'gif HTTP', 'htm HTTP', 'jpg HTTP', 'robots\.txt', 'http:\/\/blogdex\.media\.mit\.edu\/\/', ); my $ignores = join ("|",@ignores); my @log; open LG, $file or die "can't open $file $!"; while (<LG>) { next if /$ignores/; unshift @log, $_ if /$domain/; } my $count = 0; my $lastlog; while ($count < @log) { $log[$count] =~ /^(.*?) - - \[(.*?)].*?"GET \/(.*?) HTTP.*?".* +?"(.*?)".*?".*?" (.*)$/; if ($lastlog ne $1) { print hr, substr ($2, 0, 17)," &nbsp;&nbsp;&nbsp;&nbsp; ",$1, br; } $lastlog = $1; print "&nbsp;&nbsp;",b("$5/$3"); print "&nbsp;&nbsp;(from $4)" unless $4 =~ /$5/; print br; $count ++; } }

In reply to Access Log Reader by George_Sherston

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.