File Coverage

blib/lib/Logfile/Cern.pm
Criterion Covered Total %
statement 26 27 96.3
branch 17 20 85.0
condition n/a
subroutine 2 2 100.0
pod 0 2 0.0
total 45 51 88.2


line stmt bran cond sub pod time code
1             #!/usr/local/ls6/bin/perl
2             # -*- Mode: Perl -*-
3             # Cern.pm --
4             # ITIID : $ITI$ $Header $__Header$
5             # Author : Ulrich Pfeifer
6             # Created On : Mon Mar 25 09:59:37 1996
7             # Last Modified By: Ulrich Pfeifer
8             # Last Modified On: Thu May 23 15:09:04 1996
9             # Language : Perl
10             # Update Count : 11
11             # Status : Unknown, Use with caution!
12             #
13             # (C) Copyright 1996, Universität Dortmund, all rights reserved.
14             #
15             # $Locker: pfeifer $
16             # $Log: Cern.pm,v $
17             # Revision 0.1.1.4 1997/01/20 09:07:30 pfeifer
18             # patch15: -w fix by Hugo van der Sanden.
19             #
20             # Revision 0.1.1.3 1996/05/23 14:16:28 pfeifer
21             # patch11: Removed site specific stuff. Added limit to level 3 for urls.
22             #
23             # Revision 0.1.1.2 1996/03/27 14:41:35 pfeifer
24             # patch6: Renamed Tools::Logfile to Logfile.
25             #
26             # Revision 0.1.1.1 1996/03/26 13:50:04 pfeifer
27             # patch2: Renamed module to Logfile and Logfile.pm to
28             # patch2: Logfile/Base.pm
29             #
30             # Revision 0.1 1996/03/25 10:52:16 pfeifer
31             # First public version.
32             #
33             #
34              
35             package Logfile::Cern;
36             require Logfile::Base;
37              
38             @ISA = qw ( Logfile::Base ) ;
39              
40             sub next {
41 95     95 0 111 my $self = shift;
42 95         195 my $fh = $self->{Fh};
43              
44 95         294 *S = $fh;
45 95         108 my ($line,$host,$user,$pass,$rest,$date,$req,$code,$bytes);
46 95         1175 while (defined ($line = )) {
47 100         345 ($host,$user,$pass,$rest) = split ' ', $line, 4;
48 100 100       404 next unless $rest;
49 98 100       894 ($rest =~ s!\[([^\]]+)\]\s*!!) && ($date = $1);
50 98 100       802 ($rest =~ s!\"([^\"]+)\"\s*!!) && ($req = (split ' ', $1)[1]);
51 98         263 ($code, $bytes) = split ' ', $rest;
52 98 100       218 last if $date;
53             }
54 95 50       153 return undef unless $date;
55             # print "($host,$user,$pass,$date,$req,$code,$bytes)\n";
56             #print $line unless $req;
57 95         501 Logfile::Base::Record->new(Host => $host,
58             Date => $date,
59             File => $req,
60             Bytes => $bytes,
61             );
62             }
63              
64             sub norm {
65 475     475 0 700 my ($self, $key, $val) = @_;
66              
67 475 100       1028 if ($key eq File) {
    50          
68 95         220 $val =~ s/\?.*//; # remove that !!!
69 95 50       171 $val = '/' unless $val;
70 95         233 $val =~ s/\.\w+$//;
71 95         109 $val =~ s!%([\da-f][\da-f])!chr(hex($1))!eig;
  1         7  
72 95         168 $val =~ s!~(\w+)/.*!~$1!;
73             # proxy
74 95         126 $val =~ s!^((http|ftp|wais)://[^/]+)/.*!$1!;
75             # confine to depth 3
76 95         297 my @val = split /\//, $val;
77 95 100       208 $#val = 2 if $#val > 2;
78             #printf STDERR "$val => %s\n", join('/', @val) || '/';
79 95 100       486 join('/', @val) || '/';
80             } elsif ($key eq Bytes) {
81 0         0 $val =~ s/\D.*//;
82             } else {
83 380         976 $val;
84             }
85             }
86              
87             1;