line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Hash::AutoHash::AVPairsSingle; |
2
|
|
|
|
|
|
|
our $VERSION='1.17_01'; |
3
|
|
|
|
|
|
|
$VERSION=eval $VERSION; # I think this is the accepted idiom.. |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
################################################################################# |
6
|
|
|
|
|
|
|
# |
7
|
|
|
|
|
|
|
# Author: Nat Goodman |
8
|
|
|
|
|
|
|
# Created: 09-03-05 |
9
|
|
|
|
|
|
|
# $Id: |
10
|
|
|
|
|
|
|
# |
11
|
|
|
|
|
|
|
# AutoHash with single-valued, string or number elements. no references |
12
|
|
|
|
|
|
|
# |
13
|
|
|
|
|
|
|
################################################################################# |
14
|
9
|
|
|
9
|
|
154006
|
use strict; |
|
9
|
|
|
|
|
16
|
|
|
9
|
|
|
|
|
204
|
|
15
|
9
|
|
|
9
|
|
29
|
use Carp; |
|
9
|
|
|
|
|
9
|
|
|
9
|
|
|
|
|
395
|
|
16
|
9
|
|
|
9
|
|
2906
|
use Hash::AutoHash; |
|
9
|
|
|
|
|
57313
|
|
|
9
|
|
|
|
|
41
|
|
17
|
9
|
|
|
9
|
|
1117
|
use base qw(Hash::AutoHash); |
|
9
|
|
|
|
|
13
|
|
|
9
|
|
|
|
|
1289
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
our @NORMAL_EXPORT_OK=@Hash::AutoHash::EXPORT_OK; |
20
|
|
|
|
|
|
|
my $helper_class=__PACKAGE__.'::helper'; |
21
|
|
|
|
|
|
|
our @EXPORT_OK=$helper_class->EXPORT_OK; |
22
|
|
|
|
|
|
|
our @SUBCLASS_EXPORT_OK=$helper_class->SUBCLASS_EXPORT_OK; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
################################################################################# |
25
|
|
|
|
|
|
|
# helper package exists to avoid polluting Hash::AutoHash::Args namespace with |
26
|
|
|
|
|
|
|
# subs that would mask accessor/mutator AUTOLOADs |
27
|
|
|
|
|
|
|
# functions herein (except _new) are exportable by Hash::AutoHash::Args |
28
|
|
|
|
|
|
|
################################################################################# |
29
|
|
|
|
|
|
|
package Hash::AutoHash::AVPairsSingle::helper; |
30
|
|
|
|
|
|
|
our $VERSION=$Hash::AutoHash::AVPairsSingle::VERSION; |
31
|
9
|
|
|
9
|
|
38
|
use strict; |
|
9
|
|
|
|
|
13
|
|
|
9
|
|
|
|
|
148
|
|
32
|
9
|
|
|
9
|
|
28
|
use Carp; |
|
9
|
|
|
|
|
9
|
|
|
9
|
|
|
|
|
439
|
|
33
|
|
|
|
|
|
|
BEGIN { |
34
|
9
|
|
|
9
|
|
184
|
our @ISA=qw(Hash::AutoHash::helper); |
35
|
|
|
|
|
|
|
} |
36
|
9
|
|
|
9
|
|
33
|
use Hash::AutoHash qw(autohash_tie); |
|
9
|
|
|
|
|
9
|
|
|
9
|
|
|
|
|
25
|
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub _new { |
39
|
29
|
|
|
29
|
|
36686
|
my($helper_class,$class,@args)=@_; |
40
|
29
|
|
|
|
|
94
|
my $self=autohash_tie Hash::AutoHash::AVPairsSingle::tie,@args; |
41
|
29
|
|
|
|
|
119
|
bless $self,$class; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
################################################################################# |
45
|
|
|
|
|
|
|
# Tied hash which implements Hash::AutoHash::MultiValued |
46
|
|
|
|
|
|
|
################################################################################# |
47
|
|
|
|
|
|
|
package Hash::AutoHash::AVPairsSingle::tie; |
48
|
|
|
|
|
|
|
our $VERSION=$Hash::AutoHash::AVPairsSingle::VERSION; |
49
|
9
|
|
|
9
|
|
1088
|
use strict; |
|
9
|
|
|
|
|
9
|
|
|
9
|
|
|
|
|
176
|
|
50
|
9
|
|
|
9
|
|
25
|
use Carp; |
|
9
|
|
|
|
|
8
|
|
|
9
|
|
|
|
|
419
|
|
51
|
9
|
|
|
9
|
|
33
|
use Tie::Hash; |
|
9
|
|
|
|
|
11
|
|
|
9
|
|
|
|
|
275
|
|
52
|
|
|
|
|
|
|
our @ISA=qw(Tie::ExtraHash); |
53
|
9
|
|
|
9
|
|
37
|
use constant STORAGE=>0; |
|
9
|
|
|
|
|
8
|
|
|
9
|
|
|
|
|
1868
|
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub TIEHASH { |
56
|
29
|
|
|
29
|
|
276
|
my($class,@hash)=@_; |
57
|
29
|
|
|
|
|
61
|
my $self=bless [{}],$class; |
58
|
29
|
100
|
|
|
|
86
|
if (@hash==1) { # flatten if ARRAY or HASH |
59
|
4
|
|
|
|
|
49
|
my $hash=shift @hash; |
60
|
4
|
50
|
|
|
|
28
|
@hash=('ARRAY' eq ref $hash)? @$hash: ('HASH' eq ref $hash)? %$hash: (); |
|
|
100
|
|
|
|
|
|
61
|
|
|
|
|
|
|
} |
62
|
29
|
|
|
|
|
74
|
while (@hash>1) { # store initial values |
63
|
43
|
|
|
|
|
85
|
my($key,$value)=splice @hash,0,2; # shift 1st two elements |
64
|
43
|
|
|
|
|
76
|
$self->STORE($key,$value); |
65
|
|
|
|
|
|
|
} |
66
|
29
|
|
|
|
|
79
|
$self; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
sub STORE { |
69
|
84
|
|
|
84
|
|
60123
|
my($self,$key,$new)=@_; |
70
|
84
|
100
|
|
|
|
342
|
confess "Trying to store reference as value of attribute $key" if ref $new; |
71
|
83
|
|
|
|
|
243
|
$self->[STORAGE]->{$key}=$new; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
1; |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
__END__ |