File Coverage

blib/lib/Parse/AccessLogEntry.pm
Criterion Covered Total %
statement 29 30 96.6
branch 2 4 50.0
condition 1 3 33.3
subroutine 4 4 100.0
pod 0 2 0.0
total 36 43 83.7


line stmt bran cond sub pod time code
1             package Parse::AccessLogEntry;
2              
3 1     1   7286 use strict;
  1         2  
  1         29  
4 1     1   4 use warnings;
  1         3  
  1         320  
5              
6             require Exporter;
7             our $VERSION = '0.06';
8              
9             sub new
10             {
11 1     1 0 90 my $Proto=shift;
12 1   33     8 my $Class=ref($Proto) || $Proto;
13 1         1 my $Self={};
14 1         2 bless $Self;
15 1         4 return $Self;
16             }
17              
18             sub parse
19             {
20 1     1 0 7 my $Self=shift;
21 1         3 my $Line=shift;
22 1         2 my $Ref;
23             my $Rest;
24 0         0 my $R2;
25 1         15 ($Ref->{host},$Ref->{user},$Ref->{date},$Rest)= $Line=~m,^([^\s]+)\s+-\s+([^ ]+)\s+\[(.*?)\]\s+(.*),;
26 1         8 my @Dsplit=split(/\s+/,$Ref->{date});
27 1         2 $Ref->{diffgmt}=$Dsplit[1];
28 1         5 my @Ds2=split(/\:/,$Dsplit[0],2);
29 1         3 $Ref->{date}=$Ds2[0];
30 1         3 $Ref->{time}=$Ds2[1];
31 1 50       4 if ($Rest)
32             {
33 1         12 ($Ref->{rtype},$Ref->{file},$Ref->{proto},$Ref->{code},$Ref->{bytes},$R2)=split(/\s/,$Rest,6);
34 1         4 $Ref->{rtype}=~tr/\"//d;
35 1         2 $Ref->{proto}=~tr/\"//d;
36 1 50       4 if ($R2)
37             {
38 1         5 my @Split=split(/\"/,$R2);
39 1         3 $Ref->{refer}=$Split[1];
40 1         3 $Ref->{agent}=$Split[3];
41             }
42             }
43 1         5 return $Ref;
44             }
45              
46              
47             1;
48             __END__