line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WebService::CIA::Source::DBM; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
require 5.005_62; |
4
|
1
|
|
|
1
|
|
45683
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
46
|
|
5
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
33
|
|
6
|
1
|
|
|
1
|
|
6
|
use Fcntl; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
439
|
|
7
|
1
|
|
|
1
|
|
935
|
use MLDBM qw(DB_File Storable); |
|
1
|
|
|
|
|
4567
|
|
|
1
|
|
|
|
|
8
|
|
8
|
1
|
|
|
1
|
|
45
|
use Carp; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
75
|
|
9
|
1
|
|
|
1
|
|
631
|
use WebService::CIA::Source; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
757
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
@WebService::CIA::Source::DBM::ISA = ("WebService::CIA::Source"); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = '1.4'; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub new { |
16
|
|
|
|
|
|
|
|
17
|
2
|
|
|
2
|
1
|
776
|
my $proto = shift; |
18
|
2
|
|
|
|
|
4
|
my $opts = shift; |
19
|
2
|
|
33
|
|
|
13
|
my $class = ref($proto) || $proto; |
20
|
2
|
|
|
|
|
5
|
my $self = {}; |
21
|
|
|
|
|
|
|
|
22
|
2
|
50
|
|
|
|
7
|
unless (exists $opts->{DBM}) { |
23
|
0
|
|
|
|
|
0
|
croak("WebService::CIA::Source::DBM: No DBM file specified"); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
2
|
|
|
|
|
3
|
my $mode; |
27
|
2
|
100
|
66
|
|
|
23
|
if (exists $opts->{Mode} && $opts->{Mode} eq "readwrite") { |
|
|
50
|
|
|
|
|
|
28
|
1
|
50
|
|
|
|
3
|
tie %{$self->{DBM}}, "MLDBM", $opts->{DBM}, O_CREAT|O_RDWR, 0640 or croak "WebService::CIA::Source::DBM: Can't open DBM: $!"; ## no critic (ProhibitLeadingZeros) |
|
1
|
|
|
|
|
10
|
|
29
|
|
|
|
|
|
|
} elsif (-e $opts->{DBM}) { |
30
|
0
|
0
|
|
|
|
0
|
tie %{$self->{DBM}}, "MLDBM", $opts->{DBM}, O_RDONLY, 0440 or croak "WebService::CIA::Source::DBM: Can't open DBM: $!"; ## no critic (ProhibitLeadingZeros) |
|
0
|
|
|
|
|
0
|
|
31
|
|
|
|
|
|
|
} else { |
32
|
1
|
|
|
|
|
241
|
croak "WebService::CIA::Source::DBM: $opts->{DBM}: $!"; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
0
|
|
|
|
|
|
bless ($self, $class); |
36
|
0
|
|
|
|
|
|
return $self; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub value { |
41
|
|
|
|
|
|
|
|
42
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
43
|
0
|
|
|
|
|
|
my ($country, $field) = @_; |
44
|
0
|
0
|
0
|
|
|
|
if (exists $self->dbm->{$country} and exists $self->dbm->{$country}->{$field}) { |
45
|
0
|
|
|
|
|
|
return $self->dbm->{$country}->{$field}; |
46
|
|
|
|
|
|
|
} else { |
47
|
0
|
|
|
|
|
|
return; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub all { |
53
|
|
|
|
|
|
|
|
54
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
55
|
0
|
|
|
|
|
|
my $cc = shift; |
56
|
0
|
0
|
|
|
|
|
if (exists $self->dbm->{$cc}) { |
57
|
0
|
|
|
|
|
|
return $self->dbm->{$cc}; |
58
|
|
|
|
|
|
|
} else { |
59
|
0
|
|
|
|
|
|
return {}; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub set { |
65
|
|
|
|
|
|
|
|
66
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
67
|
0
|
|
|
|
|
|
my ($cc, $data) = @_; |
68
|
0
|
|
|
|
|
|
$self->dbm->{$cc} = $data; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub dbm { |
73
|
|
|
|
|
|
|
|
74
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
75
|
0
|
|
|
|
|
|
return $self->{DBM}; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
1; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
__END__ |