File Coverage

blib/lib/App/YG/Apache/Combined.pm
Criterion Covered Total %
statement 10 10 100.0
branch 2 2 100.0
condition 18 18 100.0
subroutine 4 4 100.0
pod 2 2 100.0
total 36 36 100.0


line stmt bran cond sub pod time code
1             package App::YG::Apache::Combined;
2 3     3   38571 use strict;
  3         5  
  3         127  
3 3     3   14 use warnings;
  3         4  
  3         809  
4              
5             # 127.0.0.1 - - [30/Sep/2012:12:34:56 +0900] "GET /foo HTTP/1.0" 200 123 "http://example.com/" "Mozilla/5.0"
6             our $regexp = qr/^
7             ([^\ ]+)\ +([^\ ]+)\ +([^\ ]+)\ +
8             \[([^\]]+)\]\ +
9             "(.*)"\ +(\d+)\ +([^\ ]+)\ +
10             "(.*)"\ +"(.*)"
11             $/x;
12              
13             sub parse {
14 4     4 1 17560 my $line = shift;
15              
16 4 100       59 $line =~ m!$regexp! or warn "failed to parse line: '$line'\n";
17              
18             return [
19 4   100     239 $1 || '', $2 || '', $3 || '',
      100        
      100        
      100        
      100        
      100        
      100        
      100        
      100        
20             $4 || '',
21             $5 || '', $6 || '', $7 || '',
22             $8 || '', $9 || '',
23             ];
24             }
25              
26             sub labels {
27 1     1 1 9 return [qw/
28             Host
29             Ident
30             Authuser
31             Date
32             Request
33             Status
34             Bytes
35             Referer
36             UserAgent
37             /];
38             }
39              
40             1;
41              
42             __END__