line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Hash::Merge; |
2
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
373622
|
use strict; |
|
6
|
|
|
|
|
71
|
|
|
6
|
|
|
|
|
192
|
|
4
|
6
|
|
|
6
|
|
31
|
use warnings; |
|
6
|
|
|
|
|
8
|
|
|
6
|
|
|
|
|
148
|
|
5
|
|
|
|
|
|
|
|
6
|
6
|
|
|
6
|
|
27
|
use Carp; |
|
6
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
375
|
|
7
|
6
|
|
|
6
|
|
2527
|
use Clone::Choose 0.008; |
|
6
|
|
|
|
|
18165
|
|
|
6
|
|
|
|
|
31
|
|
8
|
6
|
|
|
6
|
|
11334
|
use Scalar::Util qw(blessed weaken); |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
319
|
|
9
|
|
|
|
|
|
|
|
10
|
6
|
|
|
6
|
|
36
|
use base 'Exporter'; |
|
6
|
|
|
|
|
18
|
|
|
6
|
|
|
|
|
8711
|
|
11
|
|
|
|
|
|
|
our $CONTEXT; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = '0.301'; |
14
|
|
|
|
|
|
|
our @EXPORT_OK = qw( merge _hashify _merge_hashes ); |
15
|
|
|
|
|
|
|
our %EXPORT_TAGS = ('custom' => [qw( _hashify _merge_hashes )]); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub _init |
18
|
|
|
|
|
|
|
{ |
19
|
10
|
|
|
10
|
|
22
|
my $self = shift; |
20
|
|
|
|
|
|
|
|
21
|
10
|
|
|
|
|
16
|
my $weak = $self; |
22
|
10
|
|
|
|
|
61
|
weaken $weak; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
defined $self->{behaviors} |
25
|
|
|
|
|
|
|
or $self->{behaviors} = { |
26
|
|
|
|
|
|
|
'LEFT_PRECEDENT' => { |
27
|
|
|
|
|
|
|
'SCALAR' => { |
28
|
10
|
|
|
10
|
|
43
|
'SCALAR' => sub { $_[0] }, |
29
|
4
|
|
|
4
|
|
13
|
'ARRAY' => sub { $_[0] }, |
30
|
8
|
|
|
8
|
|
37
|
'HASH' => sub { $_[0] }, |
31
|
|
|
|
|
|
|
}, |
32
|
|
|
|
|
|
|
'ARRAY' => { |
33
|
4
|
|
|
4
|
|
8
|
'SCALAR' => sub { [@{$_[0]}, $_[1]] }, |
|
4
|
|
|
|
|
18
|
|
34
|
4
|
|
|
4
|
|
9
|
'ARRAY' => sub { [@{$_[0]}, @{$_[1]}] }, |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
18
|
|
35
|
8
|
|
|
8
|
|
12
|
'HASH' => sub { [@{$_[0]}, values %{$_[1]}] }, |
|
8
|
|
|
|
|
16
|
|
|
8
|
|
|
|
|
40
|
|
36
|
|
|
|
|
|
|
}, |
37
|
|
|
|
|
|
|
'HASH' => { |
38
|
8
|
|
|
8
|
|
20
|
'SCALAR' => sub { $_[0] }, |
39
|
8
|
|
|
8
|
|
25
|
'ARRAY' => sub { $_[0] }, |
40
|
22
|
|
|
22
|
|
54
|
'HASH' => sub { $weak->_merge_hashes($_[0], $_[1]) }, |
41
|
|
|
|
|
|
|
}, |
42
|
|
|
|
|
|
|
}, |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
'RIGHT_PRECEDENT' => { |
45
|
|
|
|
|
|
|
'SCALAR' => { |
46
|
8
|
|
|
8
|
|
29
|
'SCALAR' => sub { $_[1] }, |
47
|
4
|
|
|
4
|
|
8
|
'ARRAY' => sub { [$_[0], @{$_[1]}] }, |
|
4
|
|
|
|
|
19
|
|
48
|
8
|
|
|
8
|
|
22
|
'HASH' => sub { $_[1] }, |
49
|
|
|
|
|
|
|
}, |
50
|
|
|
|
|
|
|
'ARRAY' => { |
51
|
4
|
|
|
4
|
|
15
|
'SCALAR' => sub { $_[1] }, |
52
|
4
|
|
|
4
|
|
8
|
'ARRAY' => sub { [@{$_[0]}, @{$_[1]}] }, |
|
4
|
|
|
|
|
11
|
|
|
4
|
|
|
|
|
16
|
|
53
|
8
|
|
|
8
|
|
27
|
'HASH' => sub { $_[1] }, |
54
|
|
|
|
|
|
|
}, |
55
|
|
|
|
|
|
|
'HASH' => { |
56
|
8
|
|
|
8
|
|
30
|
'SCALAR' => sub { $_[1] }, |
57
|
8
|
|
|
8
|
|
14
|
'ARRAY' => sub { [values %{$_[0]}, @{$_[1]}] }, |
|
8
|
|
|
|
|
25
|
|
|
8
|
|
|
|
|
32
|
|
58
|
20
|
|
|
20
|
|
49
|
'HASH' => sub { $weak->_merge_hashes($_[0], $_[1]) }, |
59
|
|
|
|
|
|
|
}, |
60
|
|
|
|
|
|
|
}, |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
'STORAGE_PRECEDENT' => { |
63
|
|
|
|
|
|
|
'SCALAR' => { |
64
|
8
|
|
|
8
|
|
26
|
'SCALAR' => sub { $_[0] }, |
65
|
4
|
|
|
4
|
|
9
|
'ARRAY' => sub { [$_[0], @{$_[1]}] }, |
|
4
|
|
|
|
|
15
|
|
66
|
8
|
|
|
8
|
|
24
|
'HASH' => sub { $_[1] }, |
67
|
|
|
|
|
|
|
}, |
68
|
|
|
|
|
|
|
'ARRAY' => { |
69
|
4
|
|
|
4
|
|
11
|
'SCALAR' => sub { [@{$_[0]}, $_[1]] }, |
|
4
|
|
|
|
|
60
|
|
70
|
4
|
|
|
4
|
|
7
|
'ARRAY' => sub { [@{$_[0]}, @{$_[1]}] }, |
|
4
|
|
|
|
|
11
|
|
|
4
|
|
|
|
|
19
|
|
71
|
8
|
|
|
8
|
|
24
|
'HASH' => sub { $_[1] }, |
72
|
|
|
|
|
|
|
}, |
73
|
|
|
|
|
|
|
'HASH' => { |
74
|
8
|
|
|
8
|
|
23
|
'SCALAR' => sub { $_[0] }, |
75
|
8
|
|
|
8
|
|
26
|
'ARRAY' => sub { $_[0] }, |
76
|
20
|
|
|
20
|
|
50
|
'HASH' => sub { $weak->_merge_hashes($_[0], $_[1]) }, |
77
|
|
|
|
|
|
|
}, |
78
|
|
|
|
|
|
|
}, |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
'RETAINMENT_PRECEDENT' => { |
81
|
|
|
|
|
|
|
'SCALAR' => { |
82
|
8
|
|
|
8
|
|
28
|
'SCALAR' => sub { [$_[0], $_[1]] }, |
83
|
4
|
|
|
4
|
|
11
|
'ARRAY' => sub { [$_[0], @{$_[1]}] }, |
|
4
|
|
|
|
|
18
|
|
84
|
8
|
|
|
8
|
|
25
|
'HASH' => sub { $weak->_merge_hashes($weak->_hashify($_[0]), $_[1]) }, |
85
|
|
|
|
|
|
|
}, |
86
|
|
|
|
|
|
|
'ARRAY' => { |
87
|
4
|
|
|
4
|
|
8
|
'SCALAR' => sub { [@{$_[0]}, $_[1]] }, |
|
4
|
|
|
|
|
21
|
|
88
|
4
|
|
|
4
|
|
8
|
'ARRAY' => sub { [@{$_[0]}, @{$_[1]}] }, |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
20
|
|
89
|
8
|
|
|
8
|
|
21
|
'HASH' => sub { $weak->_merge_hashes($weak->_hashify($_[0]), $_[1]) }, |
90
|
|
|
|
|
|
|
}, |
91
|
|
|
|
|
|
|
'HASH' => { |
92
|
8
|
|
|
8
|
|
22
|
'SCALAR' => sub { $weak->_merge_hashes($_[0], $weak->_hashify($_[1])) }, |
93
|
8
|
|
|
8
|
|
26
|
'ARRAY' => sub { $weak->_merge_hashes($_[0], $weak->_hashify($_[1])) }, |
94
|
20
|
|
|
20
|
|
51
|
'HASH' => sub { $weak->_merge_hashes($_[0], $_[1]) }, |
95
|
|
|
|
|
|
|
}, |
96
|
|
|
|
|
|
|
}, |
97
|
10
|
50
|
|
|
|
668
|
}; |
98
|
|
|
|
|
|
|
|
99
|
10
|
50
|
|
|
|
57
|
defined $self->{behavior} or $self->{behavior} = 'LEFT_PRECEDENT'; |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
croak "Behavior '$self->{behavior}' does not exist" |
102
|
10
|
50
|
|
|
|
43
|
if !exists $self->{behaviors}{$self->{behavior}}; |
103
|
|
|
|
|
|
|
|
104
|
10
|
|
|
|
|
25
|
$self->{matrix} = $self->{behaviors}{$self->{behavior}}; |
105
|
10
|
|
|
|
|
25
|
$self->{clone} = 1; |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub new |
109
|
|
|
|
|
|
|
{ |
110
|
10
|
|
|
10
|
0
|
15897
|
my ($pkg, $beh) = @_; |
111
|
10
|
|
33
|
|
|
48
|
$pkg = ref $pkg || $pkg; |
112
|
|
|
|
|
|
|
|
113
|
10
|
50
|
|
|
|
59
|
my $instance = bless {($beh ? (behavior => $beh) : ())}, $pkg; |
114
|
10
|
|
|
|
|
38
|
$instance->_init; |
115
|
|
|
|
|
|
|
|
116
|
10
|
|
|
|
|
27
|
return $instance; |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
sub set_behavior |
120
|
|
|
|
|
|
|
{ |
121
|
16
|
|
|
16
|
1
|
99991
|
my $self = &_get_obj; # '&' + no args modifies current @_ |
122
|
16
|
|
|
|
|
29
|
my $value = shift; |
123
|
|
|
|
|
|
|
|
124
|
16
|
|
|
|
|
25
|
my @behaviors = grep { /^$value$/i } keys %{$self->{'behaviors'}}; |
|
64
|
|
|
|
|
407
|
|
|
16
|
|
|
|
|
59
|
|
125
|
16
|
50
|
|
|
|
50
|
if (scalar @behaviors == 0) |
126
|
|
|
|
|
|
|
{ |
127
|
0
|
|
|
|
|
0
|
carp 'Behavior must be one of : ' . join(', ', keys %{$self->{'behaviors'}}); |
|
0
|
|
|
|
|
0
|
|
128
|
0
|
|
|
|
|
0
|
return; |
129
|
|
|
|
|
|
|
} |
130
|
16
|
50
|
|
|
|
50
|
if (scalar @behaviors > 1) |
131
|
|
|
|
|
|
|
{ |
132
|
0
|
|
|
|
|
0
|
croak 'Behavior must be unique in uppercase letters! You specified: ' . join ', ', @behaviors; |
133
|
|
|
|
|
|
|
} |
134
|
16
|
50
|
|
|
|
34
|
if (scalar @behaviors == 1) |
135
|
|
|
|
|
|
|
{ |
136
|
16
|
|
|
|
|
28
|
$value = $behaviors[0]; |
137
|
|
|
|
|
|
|
} |
138
|
|
|
|
|
|
|
|
139
|
16
|
|
|
|
|
30
|
my $oldvalue = $self->{'behavior'}; |
140
|
16
|
|
|
|
|
27
|
$self->{'behavior'} = $value; |
141
|
16
|
|
|
|
|
38
|
$self->{'matrix'} = $self->{'behaviors'}{$value}; |
142
|
16
|
|
|
|
|
78
|
return $oldvalue; # Use classic POSIX pattern for get/set: set returns previous value |
143
|
|
|
|
|
|
|
} |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
sub get_behavior |
146
|
|
|
|
|
|
|
{ |
147
|
6
|
|
|
6
|
1
|
30
|
my $self = &_get_obj; # '&' + no args modifies current @_ |
148
|
6
|
|
|
|
|
29
|
return $self->{'behavior'}; |
149
|
|
|
|
|
|
|
} |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
sub add_behavior_spec |
152
|
|
|
|
|
|
|
{ |
153
|
8
|
|
|
8
|
1
|
34698
|
my $self = &_get_obj; # '&' + no args modifies current @_ |
154
|
8
|
|
|
|
|
20
|
my ($matrix, $name) = @_; |
155
|
8
|
|
50
|
|
|
26
|
$name ||= 'user defined'; |
156
|
8
|
100
|
|
|
|
33
|
if (exists $self->{'behaviors'}{$name}) |
157
|
|
|
|
|
|
|
{ |
158
|
4
|
|
|
|
|
753
|
carp "Behavior '$name' was already defined. Please take another name"; |
159
|
4
|
|
|
|
|
339
|
return; |
160
|
|
|
|
|
|
|
} |
161
|
|
|
|
|
|
|
|
162
|
4
|
|
|
|
|
14
|
my @required = qw( SCALAR ARRAY HASH ); |
163
|
|
|
|
|
|
|
|
164
|
4
|
|
|
|
|
48
|
foreach my $left (@required) |
165
|
|
|
|
|
|
|
{ |
166
|
12
|
|
|
|
|
34
|
foreach my $right (@required) |
167
|
|
|
|
|
|
|
{ |
168
|
36
|
50
|
|
|
|
68
|
if (!exists $matrix->{$left}->{$right}) |
169
|
|
|
|
|
|
|
{ |
170
|
0
|
|
|
|
|
0
|
carp "Behavior does not specify action for '$left' merging with '$right'"; |
171
|
0
|
|
|
|
|
0
|
return; |
172
|
|
|
|
|
|
|
} |
173
|
|
|
|
|
|
|
} |
174
|
|
|
|
|
|
|
} |
175
|
|
|
|
|
|
|
|
176
|
4
|
|
|
|
|
10
|
$self->{'behavior'} = $name; |
177
|
4
|
|
|
|
|
17
|
$self->{'behaviors'}{$name} = $self->{'matrix'} = $matrix; |
178
|
|
|
|
|
|
|
} |
179
|
|
|
|
|
|
|
|
180
|
6
|
|
|
6
|
|
53
|
no strict "refs"; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
307
|
|
181
|
|
|
|
|
|
|
*specify_behavior = \&add_behavior_spec; |
182
|
6
|
|
|
6
|
|
33
|
use strict; |
|
6
|
|
|
|
|
17
|
|
|
6
|
|
|
|
|
3749
|
|
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
sub get_behavior_spec |
185
|
|
|
|
|
|
|
{ |
186
|
4
|
|
|
4
|
1
|
60
|
my $self = &_get_obj; # '&' + no args modifies current @_ |
187
|
4
|
|
|
|
|
13
|
my ($name) = @_; |
188
|
4
|
|
50
|
|
|
13
|
$name ||= 'user defined'; |
189
|
4
|
50
|
|
|
|
22
|
exists $self->{'behaviors'}{$name} and return $self->{'behaviors'}{$name}; |
190
|
|
|
|
|
|
|
return: |
191
|
|
|
|
|
|
|
} |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
sub set_clone_behavior |
194
|
|
|
|
|
|
|
{ |
195
|
0
|
|
|
0
|
1
|
0
|
my $self = &_get_obj; # '&' + no args modifies current @_ |
196
|
0
|
|
|
|
|
0
|
my $oldvalue = $self->{'clone'}; |
197
|
0
|
0
|
|
|
|
0
|
$self->{'clone'} = shift() ? 1 : 0; |
198
|
0
|
|
|
|
|
0
|
return $oldvalue; |
199
|
|
|
|
|
|
|
} |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
sub get_clone_behavior |
202
|
|
|
|
|
|
|
{ |
203
|
0
|
|
|
0
|
1
|
0
|
my $self = &_get_obj; # '&' + no args modifies current @_ |
204
|
0
|
|
|
|
|
0
|
return $self->{'clone'}; |
205
|
|
|
|
|
|
|
} |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
sub merge |
208
|
|
|
|
|
|
|
{ |
209
|
298
|
|
|
298
|
1
|
19124
|
my $self = &_get_obj; # '&' + no args modifies current @_ |
210
|
|
|
|
|
|
|
|
211
|
298
|
|
|
|
|
516
|
my ($left, $right) = @_; |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
# For the general use of this module, we want to create duplicates |
214
|
|
|
|
|
|
|
# of all data that is merged. This behavior can be shut off, but |
215
|
|
|
|
|
|
|
# can create havoc if references are used heavily. |
216
|
|
|
|
|
|
|
|
217
|
298
|
|
|
|
|
414
|
my $lefttype = ref($left); |
218
|
298
|
100
|
66
|
|
|
890
|
$lefttype = "SCALAR" unless defined $lefttype and defined $self->{'matrix'}->{$lefttype}; |
219
|
|
|
|
|
|
|
|
220
|
298
|
|
|
|
|
394
|
my $righttype = ref($right); |
221
|
298
|
100
|
66
|
|
|
744
|
$righttype = "SCALAR" unless defined $righttype and defined $self->{'matrix'}->{$righttype}; |
222
|
|
|
|
|
|
|
|
223
|
298
|
50
|
|
|
|
451
|
if ($self->{'clone'}) |
224
|
|
|
|
|
|
|
{ |
225
|
298
|
100
|
|
|
|
5960
|
$left = ref($left) ? clone($left) : $left; |
226
|
298
|
100
|
|
|
|
4277
|
$right = ref($right) ? clone($right) : $right; |
227
|
|
|
|
|
|
|
} |
228
|
|
|
|
|
|
|
|
229
|
298
|
|
|
|
|
486
|
local $CONTEXT = $self; |
230
|
298
|
|
|
|
|
704
|
return $self->{'matrix'}->{$lefttype}{$righttype}->($left, $right); |
231
|
|
|
|
|
|
|
} |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
# This does a straight merge of hashes, delegating the merge-specific |
234
|
|
|
|
|
|
|
# work to 'merge' |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
sub _merge_hashes |
237
|
|
|
|
|
|
|
{ |
238
|
114
|
|
|
114
|
|
154
|
my $self = &_get_obj; # '&' + no args modifies current @_ |
239
|
|
|
|
|
|
|
|
240
|
114
|
|
|
|
|
201
|
my ($left, $right) = (shift, shift); |
241
|
114
|
50
|
33
|
|
|
364
|
if (ref $left ne 'HASH' || ref $right ne 'HASH') |
242
|
|
|
|
|
|
|
{ |
243
|
0
|
|
|
|
|
0
|
carp 'Arguments for _merge_hashes must be hash references'; |
244
|
0
|
|
|
|
|
0
|
return; |
245
|
|
|
|
|
|
|
} |
246
|
|
|
|
|
|
|
|
247
|
114
|
|
|
|
|
136
|
my %newhash; |
248
|
114
|
|
|
|
|
298
|
foreach my $key (keys %$left) |
249
|
|
|
|
|
|
|
{ |
250
|
|
|
|
|
|
|
$newhash{$key} = |
251
|
|
|
|
|
|
|
exists $right->{$key} |
252
|
|
|
|
|
|
|
? $self->merge($left->{$key}, $right->{$key}) |
253
|
362
|
100
|
|
|
|
863
|
: $left->{$key}; |
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
} |
256
|
|
|
|
|
|
|
|
257
|
114
|
|
|
|
|
282
|
foreach my $key (grep { !exists $left->{$_} } keys %$right) |
|
362
|
|
|
|
|
598
|
|
258
|
|
|
|
|
|
|
{ |
259
|
88
|
|
|
|
|
143
|
$newhash{$key} = $right->{$key}; |
260
|
|
|
|
|
|
|
} |
261
|
|
|
|
|
|
|
|
262
|
114
|
|
|
|
|
567
|
return \%newhash; |
263
|
|
|
|
|
|
|
} |
264
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
# Given a scalar or an array, creates a new hash where for each item in |
266
|
|
|
|
|
|
|
# the passed scalar or array, the key is equal to the value. Returns |
267
|
|
|
|
|
|
|
# this new hash |
268
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
sub _hashify |
270
|
|
|
|
|
|
|
{ |
271
|
32
|
|
|
32
|
|
50
|
my $self = &_get_obj; # '&' + no args modifies current @_ |
272
|
32
|
|
|
|
|
53
|
my $arg = shift; |
273
|
32
|
50
|
|
|
|
60
|
if (ref $arg eq 'HASH') |
274
|
|
|
|
|
|
|
{ |
275
|
0
|
|
|
|
|
0
|
carp 'Arguement for _hashify must not be a HASH ref'; |
276
|
0
|
|
|
|
|
0
|
return; |
277
|
|
|
|
|
|
|
} |
278
|
|
|
|
|
|
|
|
279
|
32
|
|
|
|
|
37
|
my %newhash; |
280
|
32
|
100
|
|
|
|
60
|
if (ref $arg eq 'ARRAY') |
281
|
|
|
|
|
|
|
{ |
282
|
16
|
|
|
|
|
29
|
foreach my $item (@$arg) |
283
|
|
|
|
|
|
|
{ |
284
|
32
|
|
|
|
|
35
|
my $suffix = 2; |
285
|
32
|
|
|
|
|
37
|
my $name = $item; |
286
|
32
|
|
|
|
|
56
|
while (exists $newhash{$name}) |
287
|
|
|
|
|
|
|
{ |
288
|
0
|
|
|
|
|
0
|
$name = $item . $suffix++; |
289
|
|
|
|
|
|
|
} |
290
|
32
|
|
|
|
|
67
|
$newhash{$name} = $item; |
291
|
|
|
|
|
|
|
} |
292
|
|
|
|
|
|
|
} |
293
|
|
|
|
|
|
|
else |
294
|
|
|
|
|
|
|
{ |
295
|
16
|
|
|
|
|
30
|
$newhash{$arg} = $arg; |
296
|
|
|
|
|
|
|
} |
297
|
32
|
|
|
|
|
84
|
return \%newhash; |
298
|
|
|
|
|
|
|
} |
299
|
|
|
|
|
|
|
|
300
|
|
|
|
|
|
|
my $_global; |
301
|
|
|
|
|
|
|
|
302
|
|
|
|
|
|
|
sub _get_obj |
303
|
|
|
|
|
|
|
{ |
304
|
478
|
100
|
|
478
|
|
916
|
if (my $type = ref $_[0]) |
305
|
|
|
|
|
|
|
{ |
306
|
|
|
|
|
|
|
return shift() |
307
|
466
|
100
|
33
|
|
|
1130
|
if $type eq __PACKAGE__ |
|
|
|
66
|
|
|
|
|
308
|
|
|
|
|
|
|
|| (blessed $_[0] && $_[0]->isa(__PACKAGE__)); |
309
|
|
|
|
|
|
|
} |
310
|
|
|
|
|
|
|
|
311
|
28
|
50
|
|
|
|
68
|
defined $CONTEXT and return $CONTEXT; |
312
|
28
|
100
|
|
|
|
76
|
defined $_global or $_global = Hash::Merge->new; |
313
|
28
|
|
|
|
|
45
|
return $_global; |
314
|
|
|
|
|
|
|
} |
315
|
|
|
|
|
|
|
|
316
|
|
|
|
|
|
|
1; |
317
|
|
|
|
|
|
|
|
318
|
|
|
|
|
|
|
__END__ |