line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Hash::RestrictedKeys::Tie; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
54520
|
use strict; |
|
4
|
|
|
|
|
14
|
|
|
4
|
|
|
|
|
94
|
|
4
|
4
|
|
|
4
|
|
17
|
use warnings; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
88
|
|
5
|
4
|
|
|
4
|
|
17
|
use Carp qw/croak/; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
1508
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub TIEHASH { |
8
|
3
|
|
|
3
|
|
80
|
my ($class, @keys) = @_; |
9
|
3
|
|
|
|
|
17
|
bless { |
10
|
|
|
|
|
|
|
hash => {}, |
11
|
|
|
|
|
|
|
allowed_keys => \@keys |
12
|
|
|
|
|
|
|
}, $class; |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub STORE { |
16
|
11
|
|
|
11
|
|
514
|
$_[0]->{hash}->{$_[0]->_VALIDKEY($_[1])} = $_[2]; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub FETCH { |
20
|
6
|
|
|
6
|
|
1160
|
$_[0]->{hash}->{$_[0]->_VALIDKEY($_[1])}; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub _VALIDKEY { |
24
|
2
|
|
|
|
|
329
|
croak sprintf('Invalid key %s. Allowed keys: %s', $_[1], join( ', ', @{$_[0]->{allowed_keys}})) |
25
|
19
|
100
|
|
19
|
|
26
|
unless grep { $_ eq $_[1] } @{$_[0]->{allowed_keys}}; |
|
57
|
|
|
|
|
117
|
|
|
19
|
|
|
|
|
37
|
|
26
|
17
|
|
|
|
|
54
|
return $_[1]; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub FIRSTKEY { |
30
|
1
|
|
|
1
|
|
1
|
each %{ $_[0]->{hash} }; |
|
1
|
|
|
|
|
5
|
|
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub NEXTKEY { |
34
|
3
|
|
|
3
|
|
4
|
each %{ $_[0]->{hash} }; |
|
3
|
|
|
|
|
8
|
|
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub EXISTS { |
38
|
1
|
|
|
1
|
|
3
|
exists $_[0]->{hash}->{$_[0]->_VALIDKEY($_[1])}; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub DELETE { |
42
|
1
|
|
|
1
|
|
3
|
delete $_[0]->{hash}->{$_[0]->_VALIDKEY($_[1])}; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub CLEAR { |
46
|
1
|
|
|
1
|
|
2
|
%{$_[0]->{hash}} = (); |
|
1
|
|
|
|
|
5
|
|
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub SCALAR { |
50
|
1
|
|
|
1
|
|
2
|
scalar keys %{$_[0]->{hash}}; |
|
1
|
|
|
|
|
4
|
|
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
1; |