line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Copyrights 2002-2003,2007-2012 by Mark Overmeer. |
2
|
|
|
|
|
|
|
# For other contributors see ChangeLog. |
3
|
|
|
|
|
|
|
# See the manual pages for details on the licensing terms. |
4
|
|
|
|
|
|
|
# Pod stripped from pm file by OODoc 2.00. |
5
|
2
|
|
|
2
|
|
56059
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
92
|
|
6
|
2
|
|
|
2
|
|
14
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
115
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
package Hash::Case::Preserve; |
9
|
2
|
|
|
2
|
|
11
|
use vars '$VERSION'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
166
|
|
10
|
|
|
|
|
|
|
$VERSION = '1.02'; |
11
|
|
|
|
|
|
|
|
12
|
2
|
|
|
2
|
|
11
|
use base 'Hash::Case'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
1922
|
|
13
|
|
|
|
|
|
|
|
14
|
2
|
|
|
2
|
|
24
|
use Log::Report 'hash-case'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
10
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub init($) |
18
|
6
|
|
|
6
|
0
|
13
|
{ my ($self, $args) = @_; |
19
|
|
|
|
|
|
|
|
20
|
6
|
|
|
|
|
37
|
$self->{HCP_data} = {}; |
21
|
6
|
|
|
|
|
18
|
$self->{HCP_keys} = {}; |
22
|
|
|
|
|
|
|
|
23
|
6
|
|
50
|
|
|
25
|
my $keep = $args->{keep} || 'LAST'; |
24
|
6
|
100
|
|
|
|
24
|
if($keep eq 'LAST') { $self->{HCP_update} = 1 } |
|
3
|
50
|
|
|
|
7
|
|
25
|
3
|
|
|
|
|
11
|
elsif($keep eq 'FIRST') { $self->{HCP_update} = 0 } |
26
|
|
|
|
|
|
|
else |
27
|
0
|
|
|
|
|
0
|
{ error "use 'FIRST' or 'LAST' with the option keep"; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
6
|
|
|
|
|
37
|
$self->SUPER::native_init($args); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# Maintain two hashes within this object: one to store the values, and |
34
|
|
|
|
|
|
|
# one to preserve the casing. The main object also stores the options. |
35
|
|
|
|
|
|
|
# The data is kept under lower cased keys. |
36
|
|
|
|
|
|
|
|
37
|
30
|
|
|
30
|
|
10188
|
sub FETCH($) { $_[0]->{HCP_data}{lc $_[1]} } |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub STORE($$) |
40
|
16
|
|
|
16
|
|
3448
|
{ my ($self, $key, $value) = @_; |
41
|
16
|
|
|
|
|
83
|
my $lckey = lc $key; |
42
|
|
|
|
|
|
|
|
43
|
16
|
100
|
100
|
|
|
130
|
$self->{HCP_keys}{$lckey} = $key |
44
|
|
|
|
|
|
|
if $self->{HCP_update} || !exists $self->{HCP_keys}{$lckey}; |
45
|
|
|
|
|
|
|
|
46
|
16
|
|
|
|
|
82
|
$self->{HCP_data}{$lckey} = $value; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub FIRSTKEY |
50
|
26
|
|
|
26
|
|
8291
|
{ my $self = shift; |
51
|
26
|
|
|
|
|
38
|
my $a = scalar keys %{$self->{HCP_keys}}; |
|
26
|
|
|
|
|
68
|
|
52
|
26
|
|
|
|
|
65
|
$self->NEXTKEY; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub NEXTKEY($) |
56
|
56
|
|
|
56
|
|
98
|
{ my $self = shift; |
57
|
56
|
100
|
|
|
|
62
|
if(my ($k, $v) = each %{$self->{HCP_keys}}) |
|
56
|
|
|
|
|
329
|
|
58
|
30
|
50
|
|
|
|
161
|
{ return wantarray ? ($v, $self->{HCP_data}{$k}) : $v; |
59
|
|
|
|
|
|
|
} |
60
|
26
|
|
|
|
|
108
|
else { return () } |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
2
|
|
|
2
|
|
5461
|
sub EXISTS($) { exists $_[0]->{HCP_data}{lc $_[1]} } |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub DELETE($) |
66
|
2
|
|
|
2
|
|
7
|
{ my $lckey = lc $_[1]; |
67
|
2
|
|
|
|
|
10
|
delete $_[0]->{HCP_keys}{$lckey}; |
68
|
2
|
|
|
|
|
14
|
delete $_[0]->{HCP_data}{$lckey}; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub CLEAR() |
72
|
2
|
|
|
2
|
|
9
|
{ %{$_[0]->{HCP_data}} = (); |
|
2
|
|
|
|
|
11
|
|
73
|
2
|
|
|
|
|
5
|
%{$_[0]->{HCP_keys}} = (); |
|
2
|
|
|
|
|
12
|
|
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
1; |