line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Hash::Lazy::Tie; |
2
|
6
|
|
|
6
|
|
36
|
use strict; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
234
|
|
3
|
6
|
|
|
6
|
|
31
|
use warnings; |
|
6
|
|
|
|
|
13
|
|
|
6
|
|
|
|
|
333
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
BEGIN { |
6
|
6
|
|
|
6
|
|
6052
|
require Tie::Hash; |
7
|
6
|
|
|
|
|
7138
|
our @ISA = qw(Tie::ExtraHash); |
8
|
|
|
|
|
|
|
} |
9
|
|
|
|
|
|
|
|
10
|
6
|
|
|
6
|
|
42
|
use Carp qw(confess); |
|
6
|
|
|
|
|
13
|
|
|
6
|
|
|
|
|
306
|
|
11
|
6
|
|
|
6
|
|
9514
|
use self; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
use constant USAGE => 'my %h; tie %h, "Hash::Lazy::Tie", $builder, \%h;'; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
use constant STORAGE => 0; |
16
|
|
|
|
|
|
|
use constant BUILDER => 1; |
17
|
|
|
|
|
|
|
use constant TIED => 2; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub TIEHASH { |
20
|
|
|
|
|
|
|
my ($builder, $tied) = @args; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
return bless [{}, $builder, $tied], $self; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub FETCH { |
29
|
|
|
|
|
|
|
my ($key) = @args; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
return $self->[STORAGE]{$key} if exists $self->[STORAGE]{$key}; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
my $ret = $self->[BUILDER]->($self->[TIED], $key); |
34
|
|
|
|
|
|
|
$self->[STORAGE]{$key} = $ret unless exists $self->[STORAGE]{$key}; |
35
|
|
|
|
|
|
|
return $self->[STORAGE]{$key}; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
1; |