Script I.1.4: Basic Log Parsing

Basic, no frills log parsing script.

 #!/usr/local/bin/perl

 $REGEX=q/^(\S+) (\S+) (\S+) \[([^]]+)\] "(\w+) (\S+).*" (\d+) (\S+)/;
 while (<>) {
    ($host,$rfc931,$user,$date,$request,$URL,$status,$bytes) = m/$REGEX/o;
     &collect_some_statistics;
 }
 &print_some_statistics;

 sub collect_some_statistics {
   # for you to fill in
 }

 sub print_some_statistics {
   # for you to fill in
 }


<< Previous Contents >> Next >>

Lincoln D. Stein, lstein@cshl.org
Cold Spring Harbor Laboratory
Last modified: Mon Aug 17 10:30:18 PDT 1998