line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Hash::RestrictedKeys::Tie; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
57697
|
use strict; |
|
4
|
|
|
|
|
15
|
|
|
4
|
|
|
|
|
91
|
|
4
|
4
|
|
|
4
|
|
18
|
use warnings; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
88
|
|
5
|
4
|
|
|
4
|
|
17
|
use Carp qw/croak/; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
1598
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub TIEHASH { |
8
|
3
|
|
|
3
|
|
90
|
my ($class, @keys) = @_; |
9
|
3
|
|
|
|
|
16
|
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
|
|
1178
|
$_[0]->{hash}->{$_[0]->_VALIDKEY($_[1])}; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub _VALIDKEY { |
24
|
2
|
|
|
|
|
306
|
croak sprintf('Invalid key %s. Allowed keys: %s', $_[1], join( ', ', @{$_[0]->{allowed_keys}})) |
25
|
19
|
100
|
|
19
|
|
35
|
unless grep { $_ eq $_[1] } @{$_[0]->{allowed_keys}}; |
|
57
|
|
|
|
|
112
|
|
|
19
|
|
|
|
|
46
|
|
26
|
17
|
|
|
|
|
54
|
return $_[1]; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub FIRSTKEY { |
30
|
1
|
|
|
1
|
|
1
|
each %{ $_[0]->{hash} }; |
|
1
|
|
|
|
|
7
|
|
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
|
|
|
|
|
7
|
|
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub SCALAR { |
50
|
1
|
|
|
1
|
|
2
|
scalar %{$_[0]->{hash}}; |
|
1
|
|
|
|
|
5
|
|
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
1; |