line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Hash::Lazy::Tie; |
2
|
6
|
|
|
6
|
|
36
|
use strict; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
150
|
|
3
|
6
|
|
|
6
|
|
26
|
use warnings; |
|
6
|
|
|
|
|
8
|
|
|
6
|
|
|
|
|
271
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
BEGIN { |
6
|
6
|
|
|
6
|
|
2501
|
require Tie::Hash; |
7
|
6
|
|
|
|
|
4904
|
our @ISA = qw(Tie::ExtraHash); |
8
|
|
|
|
|
|
|
} |
9
|
|
|
|
|
|
|
|
10
|
6
|
|
|
6
|
|
37
|
use Carp qw(confess); |
|
6
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
227
|
|
11
|
6
|
|
|
6
|
|
2085
|
use self; |
|
6
|
|
|
6
|
|
38116
|
|
|
6
|
|
|
|
|
30
|
|
|
6
|
|
|
|
|
6279
|
|
|
6
|
|
|
|
|
41312
|
|
|
6
|
|
|
|
|
39
|
|
12
|
|
|
|
|
|
|
|
13
|
6
|
|
|
6
|
|
1310
|
use constant USAGE => 'my %h; tie %h, "Hash::Lazy::Tie", $builder, \%h;'; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
286
|
|
14
|
|
|
|
|
|
|
|
15
|
6
|
|
|
6
|
|
513
|
use constant STORAGE => 0; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
171
|
|
16
|
6
|
|
|
6
|
|
459
|
use constant BUILDER => 1; |
|
6
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
182
|
|
17
|
6
|
|
|
6
|
|
463
|
use constant TIED => 2; |
|
6
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
178
|
|
18
|
|
|
|
|
|
|
|
19
|
5
|
|
|
5
|
|
19
|
sub TIEHASH { |
20
|
5
|
|
|
|
|
12
|
my ($builder, $tied) = @args; |
21
|
|
|
|
|
|
|
|
22
|
5
|
50
|
|
|
|
16
|
confess "The use of Hash::Lazy::Tie requires passing the hash variable that it's tying to. Usage: " . USAGE |
23
|
|
|
|
|
|
|
unless defined($tied); |
24
|
|
|
|
|
|
|
|
25
|
5
|
|
|
|
|
24
|
return bless [{}, $builder, $tied], $self; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
93
|
|
|
93
|
|
2166
|
sub FETCH { |
29
|
93
|
|
|
|
|
117
|
my ($key) = @args; |
30
|
|
|
|
|
|
|
|
31
|
93
|
100
|
|
|
|
247
|
return $self->[STORAGE]{$key} if exists $self->[STORAGE]{$key}; |
32
|
|
|
|
|
|
|
|
33
|
37
|
|
|
|
|
83
|
my $ret = $self->[BUILDER]->($self->[TIED], $key); |
34
|
37
|
100
|
|
|
|
103
|
$self->[STORAGE]{$key} = $ret unless exists $self->[STORAGE]{$key}; |
35
|
37
|
|
|
|
|
115
|
return $self->[STORAGE]{$key}; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
1; |