line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Template::Plugin::HTTP::UserAgent; |
2
|
|
|
|
|
|
|
$Template::Plugin::HTTP::UserAgent::VERSION = '0.08'; |
3
|
|
|
|
|
|
|
# ABSTRACT: Template plugin for parsing HTTP User-Agent string |
4
|
|
|
|
|
|
|
|
5
|
2
|
|
|
2
|
|
133638
|
use 5.006; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
87
|
|
6
|
2
|
|
|
2
|
|
11
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
77
|
|
7
|
2
|
|
|
2
|
|
25
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
74
|
|
8
|
2
|
|
|
2
|
|
1056
|
use parent 'Template::Plugin'; |
|
2
|
|
|
|
|
599
|
|
|
2
|
|
|
|
|
14
|
|
9
|
2
|
|
|
2
|
|
3538
|
use HTML::ParseBrowser; |
|
2
|
|
|
|
|
5167
|
|
|
2
|
|
|
|
|
403
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new |
12
|
|
|
|
|
|
|
{ |
13
|
2
|
|
|
2
|
1
|
74
|
my $class = shift; |
14
|
2
|
|
|
|
|
3
|
my $context = shift; |
15
|
2
|
|
|
|
|
2
|
my $ua; |
16
|
|
|
|
|
|
|
|
17
|
2
|
50
|
66
|
|
|
13
|
if (@_ == 0 && !exists($ENV{HTTP_USER_AGENT})) { |
18
|
0
|
|
|
|
|
0
|
return $class->error('No User-Agent string given'); |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
2
|
100
|
|
|
|
10
|
$ua = HTML::ParseBrowser->new(@_ > 0 ? shift : $ENV{HTTP_USER_AGENT}); |
22
|
|
|
|
|
|
|
|
23
|
2
|
50
|
|
|
|
443
|
if (!defined($ua)) { |
24
|
0
|
|
|
|
|
0
|
return $class->error("Failed to instantiate HTML::ParseBrowser"); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
bless { |
28
|
2
|
|
|
|
|
11
|
UA => $ua, |
29
|
|
|
|
|
|
|
}, $class; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
2
|
|
|
2
|
1
|
89
|
sub name { return $_[0]->{UA}->name; } |
33
|
2
|
|
|
2
|
1
|
56
|
sub version { return $_[0]->{UA}->v; } |
34
|
2
|
|
|
2
|
1
|
46
|
sub major { return $_[0]->{UA}->major; } |
35
|
2
|
|
|
2
|
1
|
43
|
sub minor { return $_[0]->{UA}->minor; } |
36
|
2
|
|
|
2
|
1
|
43
|
sub os { return $_[0]->{UA}->os; } |
37
|
2
|
|
|
2
|
1
|
42
|
sub ua_string { return $_[0]->{UA}->user_agent; } |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
1; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
__END__ |