File Coverage

blib/lib/Logfile/Cern.pm
Criterion Covered Total %
statement 13 27 48.1
branch 5 20 25.0
condition n/a
subroutine 1 2 50.0
pod 0 2 0.0
total 19 51 37.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 1     1 0 2 my $self = shift;
42 1         2 my $fh = $self->{Fh};
43              
44 1         4 *S = $fh;
45 1         2 my ($line,$host,$user,$pass,$rest,$date,$req,$code,$bytes);
46 1         11 while (defined ($line = )) {
47 1         5 ($host,$user,$pass,$rest) = split ' ', $line, 4;
48 1 50       4 next unless $rest;
49 1 50       10 ($rest =~ s!\[([^\]]+)\]\s*!!) && ($date = $1);
50 1 50       24 ($rest =~ s!\"([^\"]+)\"\s*!!) && ($req = (split ' ', $1)[1]);
51 1         4 ($code, $bytes) = split ' ', $rest;
52 1 50       6 last if $date;
53             }
54 1 50       4 return undef unless $date;
55             # print "($host,$user,$pass,$date,$req,$code,$bytes)\n";
56             #print $line unless $req;
57 1         10 Logfile::Base::Record->new(Host => $host,
58             Date => $date,
59             File => $req,
60             Bytes => $bytes,
61             );
62             }
63              
64             sub norm {
65 0     0 0   my ($self, $key, $val) = @_;
66              
67 0 0         if ($key eq File) {
    0          
68 0           $val =~ s/\?.*//; # remove that !!!
69 0 0         $val = '/' unless $val;
70 0           $val =~ s/\.\w+$//;
71 0           $val =~ s!%([\da-f][\da-f])!chr(hex($1))!eig;
  0            
72 0           $val =~ s!~(\w+)/.*!~$1!;
73             # proxy
74 0           $val =~ s!^((http|ftp|wais)://[^/]+)/.*!$1!;
75             # confine to depth 3
76 0           my @val = split /\//, $val;
77 0 0         $#val = 2 if $#val > 2;
78             #printf STDERR "$val => %s\n", join('/', @val) || '/';
79 0 0         join('/', @val) || '/';
80             } elsif ($key eq Bytes) {
81 0           $val =~ s/\D.*//;
82             } else {
83 0           $val;
84             }
85             }
86              
87             1;