line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Acme::Terror::UK; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
## Get and return the current UK terrorist threat status. |
4
|
|
|
|
|
|
|
## Robert Price - http://www.robertprice.co.uk/ |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
26366
|
use 5.00503; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
43
|
|
7
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
39
|
|
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
929
|
use LWP::Simple; |
|
1
|
|
|
|
|
104281
|
|
|
1
|
|
|
|
|
10
|
|
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
484
|
use vars qw($VERSION); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
54
|
|
12
|
|
|
|
|
|
|
$VERSION = '0.06'; |
13
|
|
|
|
|
|
|
|
14
|
1
|
|
|
1
|
|
5
|
use constant UNKNOWN => 0; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
63
|
|
15
|
1
|
|
|
1
|
|
5
|
use constant CRITICAL => 1; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
39
|
|
16
|
1
|
|
|
1
|
|
5
|
use constant SEVERE => 2; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
46
|
|
17
|
1
|
|
|
1
|
|
6
|
use constant SUBSTANTIAL => 3; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
50
|
|
18
|
1
|
|
|
1
|
|
5
|
use constant MODERATE => 4; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
38
|
|
19
|
1
|
|
|
1
|
|
4
|
use constant LOW => 5; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
340
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub new { |
23
|
1
|
|
|
1
|
1
|
10
|
my ($class, %args) = @_; |
24
|
1
|
50
|
|
|
|
4
|
$class = ref($class) if (ref $class); |
25
|
1
|
|
|
|
|
8
|
return bless(\%args, $class); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub fetch { |
29
|
1
|
|
|
1
|
1
|
2
|
my $self = shift; |
30
|
1
|
|
|
|
|
2
|
my $url = 'http://www.mi5.gov.uk/'; |
31
|
1
|
|
|
|
|
6
|
my $html = get($url); |
32
|
1
|
50
|
|
|
|
566651
|
return undef unless ($html); |
33
|
0
|
|
|
|
|
0
|
my ($lvl) = ($html =~ m!Current UK threat level.+?(.+?)!sgi); |
34
|
0
|
|
|
|
|
0
|
return $lvl; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub level { |
38
|
1
|
|
|
1
|
1
|
2
|
my $self = shift; |
39
|
1
|
|
|
|
|
4
|
my $level = $self->fetch(); |
40
|
1
|
50
|
|
|
|
11
|
return UNKNOWN unless ($level); |
41
|
0
|
0
|
|
|
|
|
if ($level eq 'CRITICAL') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
42
|
0
|
|
|
|
|
|
return CRITICAL; |
43
|
|
|
|
|
|
|
} elsif ($level eq 'SEVERE') { |
44
|
0
|
|
|
|
|
|
return SEVERE; |
45
|
|
|
|
|
|
|
} elsif ($level eq 'SUBSTANTIAL') { |
46
|
0
|
|
|
|
|
|
return SUBSTANTIAL; |
47
|
|
|
|
|
|
|
} elsif ($level eq 'MODERATE') { |
48
|
0
|
|
|
|
|
|
return MODERATE; |
49
|
|
|
|
|
|
|
} elsif ($level eq 'LOW') { |
50
|
0
|
|
|
|
|
|
return LOW; |
51
|
|
|
|
|
|
|
} else { |
52
|
0
|
|
|
|
|
|
return UNKNOWN; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
1; |
58
|
|
|
|
|
|
|
__END__ |