line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Module::Hash; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
79517
|
use 5.006; |
|
3
|
|
|
|
|
13
|
|
|
3
|
|
|
|
|
121
|
|
4
|
3
|
|
|
3
|
|
17
|
use strict; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
160
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
BEGIN { |
7
|
3
|
|
|
3
|
|
14
|
$Module::Hash::AUTHORITY = 'cpan:TOBYINK'; |
8
|
3
|
|
|
|
|
61
|
$Module::Hash::VERSION = '0.002'; |
9
|
|
|
|
|
|
|
} |
10
|
|
|
|
|
|
|
|
11
|
3
|
|
|
3
|
|
21
|
use base qw( Tie::Hash ); |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
3099
|
|
12
|
3
|
|
|
3
|
|
3384
|
use Carp qw( croak ); |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
140
|
|
13
|
3
|
|
|
3
|
|
4432
|
use Module::Runtime qw( use_package_optimistically use_module ); |
|
3
|
|
|
|
|
6000
|
|
|
3
|
|
|
|
|
20
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# Tied interface |
16
|
|
|
|
|
|
|
# |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub TIEHASH |
19
|
|
|
|
|
|
|
{ |
20
|
4
|
|
|
4
|
|
19
|
my $class = shift; |
21
|
4
|
|
|
|
|
15
|
return $class->new(@_); |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub STORE |
25
|
|
|
|
|
|
|
{ |
26
|
0
|
|
|
0
|
|
0
|
croak "Attempt to modify read-only hash, caught"; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub FETCH |
30
|
|
|
|
|
|
|
{ |
31
|
4
|
|
|
4
|
|
17020
|
my ($self, $key) = @_; |
32
|
4
|
|
|
|
|
20
|
return $self->use($key); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub FIRSTKEY |
36
|
|
|
|
|
|
|
{ |
37
|
0
|
|
|
0
|
|
0
|
return; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub NEXTKEY |
41
|
|
|
|
|
|
|
{ |
42
|
0
|
|
|
0
|
|
0
|
return; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub EXISTS |
46
|
|
|
|
|
|
|
{ |
47
|
0
|
|
|
0
|
|
0
|
my ($self, $key) = @_; |
48
|
0
|
|
|
|
|
0
|
defined $self->use($key); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub DELETE |
52
|
|
|
|
|
|
|
{ |
53
|
0
|
|
|
0
|
|
0
|
croak "Attempt to modify read-only hash, caught"; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub CLEAR |
57
|
|
|
|
|
|
|
{ |
58
|
0
|
|
|
0
|
|
0
|
croak "Attempt to modify read-only hash, caught"; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub SCALAR |
62
|
|
|
|
|
|
|
{ |
63
|
0
|
|
|
0
|
|
0
|
return !!1; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
# Object-oriented interface |
67
|
|
|
|
|
|
|
# |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub new |
70
|
|
|
|
|
|
|
{ |
71
|
4
|
|
|
4
|
1
|
9
|
my $class = shift; |
72
|
4
|
50
|
|
|
|
17
|
my %args = ref $_[0] eq 'HASH' ? %{$_[0]} : @_; |
|
0
|
|
|
|
|
0
|
|
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
# Defaults |
75
|
4
|
50
|
|
|
|
19
|
$args{optimistic} = 1 unless exists $args{optimistic}; |
76
|
|
|
|
|
|
|
|
77
|
4
|
|
|
|
|
7973
|
bless \%args, $class; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
4
|
|
|
4
|
1
|
31
|
sub optimistic { $_[0]{optimistic} }; |
81
|
0
|
|
|
0
|
1
|
0
|
sub prefix { $_[0]{prefix} }; |
82
|
4
|
|
|
4
|
1
|
42
|
sub has_prefix { exists $_[0]{prefix} }; |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub use |
85
|
|
|
|
|
|
|
{ |
86
|
4
|
|
|
4
|
1
|
7
|
my ($self, $module) = @_; |
87
|
|
|
|
|
|
|
|
88
|
4
|
|
|
|
|
35
|
my @mv = grep /\w/, split /\s/, $module; |
89
|
4
|
50
|
|
|
|
15
|
croak "No module name given" unless @mv; |
90
|
|
|
|
|
|
|
|
91
|
4
|
50
|
|
|
|
15
|
$mv[0] = join(q[::], $self->prefix, $mv[0]) if $self->has_prefix; |
92
|
|
|
|
|
|
|
|
93
|
4
|
50
|
|
|
|
16
|
$self->optimistic ? &use_package_optimistically(@mv) : &use_module(@mv); |
94
|
4
|
|
|
|
|
60727
|
return $mv[0]; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
# Import-oriented interface |
98
|
|
|
|
|
|
|
# |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub import |
101
|
|
|
|
|
|
|
{ |
102
|
5
|
|
|
5
|
|
37
|
my $class = shift; |
103
|
5
|
|
|
|
|
1916
|
tie %$_, $class for @_; |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
1 |
107
|
|
|
|
|
|
|
__END__ |