| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# This code is part of Perl distribution Hash-Case version 1.07. |
|
2
|
|
|
|
|
|
|
# The POD got stripped from this file by OODoc version 3.06. |
|
3
|
|
|
|
|
|
|
# For contributors see file ChangeLog. |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
# This software is copyright (c) 2002-2026 by Mark Overmeer. |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
# This is free software; you can redistribute it and/or modify it under |
|
8
|
|
|
|
|
|
|
# the same terms as the Perl 5 programming language system itself. |
|
9
|
|
|
|
|
|
|
# SPDX-License-Identifier: Artistic-1.0-Perl OR GPL-1.0-or-later |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
package Hash::Case::Preserve;{ |
|
13
|
|
|
|
|
|
|
our $VERSION = '1.07'; |
|
14
|
|
|
|
|
|
|
} |
|
15
|
|
|
|
|
|
|
|
|
16
|
2
|
|
|
2
|
|
234574
|
use base 'Hash::Case'; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
1362
|
|
|
17
|
|
|
|
|
|
|
|
|
18
|
2
|
|
|
2
|
|
17
|
use strict; |
|
|
2
|
|
|
|
|
8
|
|
|
|
2
|
|
|
|
|
49
|
|
|
19
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
|
2
|
|
|
|
|
2
|
|
|
|
2
|
|
|
|
|
102
|
|
|
20
|
|
|
|
|
|
|
|
|
21
|
2
|
|
|
2
|
|
14
|
use Carp 'croak'; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
1347
|
|
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
#-------------------- |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub init($) |
|
26
|
6
|
|
|
6
|
0
|
15
|
{ my ($self, $args) = @_; |
|
27
|
|
|
|
|
|
|
|
|
28
|
6
|
|
|
|
|
53
|
$self->{HCP_data} = {}; |
|
29
|
6
|
|
|
|
|
18
|
$self->{HCP_keys} = {}; |
|
30
|
|
|
|
|
|
|
|
|
31
|
6
|
|
50
|
|
|
24
|
my $keep = $args->{keep} || 'LAST'; |
|
32
|
6
|
100
|
|
|
|
24
|
if($keep eq 'LAST') { $self->{HCP_update} = 1 } |
|
|
3
|
50
|
|
|
|
16
|
|
|
33
|
3
|
|
|
|
|
9
|
elsif($keep eq 'FIRST') { $self->{HCP_update} = 0 } |
|
34
|
|
|
|
|
|
|
else |
|
35
|
0
|
|
|
|
|
0
|
{ croak "use 'FIRST' or 'LAST' with the option keep"; |
|
36
|
|
|
|
|
|
|
} |
|
37
|
|
|
|
|
|
|
|
|
38
|
6
|
|
|
|
|
51
|
$self->SUPER::native_init($args); |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# Maintain two hashes within this object: one to store the values, and |
|
42
|
|
|
|
|
|
|
# one to preserve the casing. The main object also stores the options. |
|
43
|
|
|
|
|
|
|
# The data is kept under lower cased keys. |
|
44
|
|
|
|
|
|
|
|
|
45
|
30
|
|
|
30
|
|
15316
|
sub FETCH($) { $_[0]->{HCP_data}{lc $_[1]} } |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub STORE($$) |
|
48
|
16
|
|
|
16
|
|
6262
|
{ my ($self, $key, $value) = @_; |
|
49
|
16
|
|
|
|
|
35
|
my $lckey = lc $key; |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
$self->{HCP_keys}{$lckey} = $key |
|
52
|
16
|
100
|
100
|
|
|
99
|
if $self->{HCP_update} || !exists $self->{HCP_keys}{$lckey}; |
|
53
|
|
|
|
|
|
|
|
|
54
|
16
|
|
|
|
|
67
|
$self->{HCP_data}{$lckey} = $value; |
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub FIRSTKEY |
|
58
|
26
|
|
|
26
|
|
13542
|
{ my $self = shift; |
|
59
|
26
|
|
|
|
|
48
|
my $a = scalar keys %{$self->{HCP_keys}}; |
|
|
26
|
|
|
|
|
80
|
|
|
60
|
26
|
|
|
|
|
74
|
$self->NEXTKEY; |
|
61
|
|
|
|
|
|
|
} |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub NEXTKEY($) |
|
64
|
56
|
|
|
56
|
|
106
|
{ my $self = shift; |
|
65
|
56
|
100
|
|
|
|
85
|
if(my ($k, $v) = each %{$self->{HCP_keys}}) |
|
|
56
|
|
|
|
|
209
|
|
|
66
|
30
|
50
|
|
|
|
160
|
{ return wantarray ? ($v, $self->{HCP_data}{$k}) : $v; |
|
67
|
|
|
|
|
|
|
} |
|
68
|
|
|
|
|
|
|
|
|
69
|
26
|
|
|
|
|
110
|
(); |
|
70
|
|
|
|
|
|
|
} |
|
71
|
|
|
|
|
|
|
|
|
72
|
2
|
|
|
2
|
|
10068
|
sub EXISTS($) { exists $_[0]->{HCP_data}{lc $_[1]} } |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub DELETE($) |
|
75
|
2
|
|
|
2
|
|
8
|
{ my $lckey = lc $_[1]; |
|
76
|
2
|
|
|
|
|
26
|
delete $_[0]->{HCP_keys}{$lckey}; |
|
77
|
2
|
|
|
|
|
14
|
delete $_[0]->{HCP_data}{$lckey}; |
|
78
|
|
|
|
|
|
|
} |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub CLEAR() |
|
81
|
2
|
|
|
2
|
|
6
|
{ %{$_[0]->{HCP_data}} = (); |
|
|
2
|
|
|
|
|
9
|
|
|
82
|
2
|
|
|
|
|
6
|
%{$_[0]->{HCP_keys}} = (); |
|
|
2
|
|
|
|
|
9
|
|
|
83
|
|
|
|
|
|
|
} |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
1; |