line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Hash::AutoHash::AVPairsMulti; |
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 multivalued string or number elements. no references |
12
|
|
|
|
|
|
|
# Inspired by Tie::Hash::Multivalue |
13
|
|
|
|
|
|
|
# |
14
|
|
|
|
|
|
|
################################################################################# |
15
|
11
|
|
|
11
|
|
218127
|
use strict; |
|
11
|
|
|
|
|
20
|
|
|
11
|
|
|
|
|
409
|
|
16
|
11
|
|
|
11
|
|
50
|
use Carp; |
|
11
|
|
|
|
|
16
|
|
|
11
|
|
|
|
|
607
|
|
17
|
11
|
|
|
11
|
|
5212
|
use Hash::AutoHash; |
|
11
|
|
|
|
|
126376
|
|
|
11
|
|
|
|
|
61
|
|
18
|
11
|
|
|
11
|
|
1961
|
use base qw(Hash::AutoHash); |
|
11
|
|
|
|
|
19
|
|
|
11
|
|
|
|
|
1985
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
our @NORMAL_EXPORT_OK=@Hash::AutoHash::EXPORT_OK; |
21
|
|
|
|
|
|
|
my $helper_class=__PACKAGE__.'::helper'; |
22
|
|
|
|
|
|
|
our @EXPORT_OK=$helper_class->EXPORT_OK; |
23
|
|
|
|
|
|
|
our @SUBCLASS_EXPORT_OK=$helper_class->SUBCLASS_EXPORT_OK; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
################################################################################# |
26
|
|
|
|
|
|
|
# helper package exists to avoid polluting Hash::AutoHash::Args namespace with |
27
|
|
|
|
|
|
|
# subs that would mask accessor/mutator AUTOLOADs |
28
|
|
|
|
|
|
|
# functions herein (except _new) are exportable by Hash::AutoHash::Args |
29
|
|
|
|
|
|
|
################################################################################# |
30
|
|
|
|
|
|
|
package Hash::AutoHash::AVPairsMulti::helper; |
31
|
|
|
|
|
|
|
our $VERSION=$Hash::AutoHash::AVPairsMulti::VERSION; |
32
|
11
|
|
|
11
|
|
55
|
use strict; |
|
11
|
|
|
|
|
18
|
|
|
11
|
|
|
|
|
234
|
|
33
|
11
|
|
|
11
|
|
43
|
use Carp; |
|
11
|
|
|
|
|
10
|
|
|
11
|
|
|
|
|
718
|
|
34
|
|
|
|
|
|
|
BEGIN { |
35
|
11
|
|
|
11
|
|
316
|
our @ISA=qw(Hash::AutoHash::helper); |
36
|
|
|
|
|
|
|
} |
37
|
11
|
|
|
11
|
|
54
|
use Hash::AutoHash qw(autohash_tie); |
|
11
|
|
|
|
|
15
|
|
|
11
|
|
|
|
|
49
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub _new { |
40
|
178
|
|
|
178
|
|
897431
|
my($helper_class,$class,@args)=@_; |
41
|
178
|
|
|
|
|
692
|
my $self=autohash_tie Hash::AutoHash::AVPairsMulti::tie,@args; |
42
|
175
|
|
|
|
|
3369
|
bless $self,$class; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
################################################################################# |
46
|
|
|
|
|
|
|
# Tied hash which implements Hash::AutoHash::AVPairsMulti |
47
|
|
|
|
|
|
|
################################################################################# |
48
|
|
|
|
|
|
|
package Hash::AutoHash::AVPairsMulti::tie; |
49
|
|
|
|
|
|
|
our $VERSION=$Hash::AutoHash::AVPairsMulti::VERSION; |
50
|
11
|
|
|
11
|
|
1751
|
use strict; |
|
11
|
|
|
|
|
18
|
|
|
11
|
|
|
|
|
273
|
|
51
|
11
|
|
|
11
|
|
45
|
use Carp; |
|
11
|
|
|
|
|
15
|
|
|
11
|
|
|
|
|
687
|
|
52
|
11
|
|
|
11
|
|
6631
|
use Hash::AutoHash::MultiValued; |
|
11
|
|
|
|
|
26913
|
|
|
11
|
|
|
|
|
70
|
|
53
|
|
|
|
|
|
|
our @ISA=qw(Hash::AutoHash::MultiValued::tie); |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub STORE { |
56
|
605
|
|
|
605
|
|
792236
|
my($self,$key,@new)=@_; |
57
|
|
|
|
|
|
|
# all values must be simple (non-reference) |
58
|
605
|
|
|
|
|
679
|
my $bad; |
59
|
605
|
100
|
100
|
|
|
3130
|
if (@new==1 && 'ARRAY' eq ref $new[0]) { # if passed ARRAY, look inside |
60
|
495
|
100
|
|
|
|
442
|
$bad=1 if grep {ref($_)} @{$new[0]}; |
|
664
|
|
|
|
|
1595
|
|
|
495
|
|
|
|
|
909
|
|
61
|
|
|
|
|
|
|
} else { |
62
|
110
|
|
|
|
|
180
|
$bad=grep {ref($_)} @new; |
|
113
|
|
|
|
|
336
|
|
63
|
|
|
|
|
|
|
} |
64
|
605
|
100
|
|
|
|
2104
|
confess "Trying to store reference as value of attribute $key" if $bad; |
65
|
598
|
|
|
|
|
1549
|
$self->SUPER::STORE($key,@new); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
1; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
__END__ |