1Hash::Case(3)         User Contributed Perl Documentation        Hash::Case(3)
2
3
4

NAME

6       Hash::Case - base class for hashes with key-casing requirements
7

INHERITANCE

9        Hash::Case
10          is a Tie::StdHash
11
12        Hash::Case is extended by
13          Hash::Case::Lower
14          Hash::Case::Preserve
15          Hash::Case::Upper
16

SYNOPSIS

18        use Hash::Case::Lower;
19        tie my(%lchash), 'Hash::Case::Lower';
20        $lchash{StraNGeKeY} = 3;
21        print keys %lchash;  # strangekey
22

DESCRIPTION

24       Hash::Case is the base class for various classes which tie special
25       treatment for the casing of keys.  Be aware of the differences in
26       implementation: "Lower" and "Upper" are tied native hashes: these
27       hashes have no need for hidden fields or other assisting data
28       structured.  A case "Preserve" hash will actually create three hashes.
29
30       The following strategies are implemented:
31
32       •   Hash::Case::Lower (native hash)
33
34           Keys are always considered lower case. The internals of this module
35           translate any incoming key to lower case before it is used.
36
37       •   Hash::Case::Upper (native hash)
38
39           Like the ::Lower, but then all keys are always translated into
40           upper case.  This module can be of use for some databases, which do
41           translate everything to capitals as well.  To avoid confusion, you
42           may want to have you own internal Perl hash do this as well.
43
44       •   Hash::Case::Preserve
45
46           The actual casing is ignored, but not forgotten.
47

METHODS

49   Constructors
50       $obj->addHashData(HASH)
51           Add the data of a hash (passed as reference) to the created tied
52           hash.  The existing values in the hash remain, the keys are adapted
53           to the needs of the the casing.
54
55       $obj->addPairs(PAIRS)
56           Specify an even length list of alternating key and value to be
57           stored in the hash.
58
59       $obj->setHash(HASH)
60           The functionality differs for native and wrapper hashes.  For
61           native hashes, this is the same as first clearing the hash, and
62           then a call to addHashData().  Wrapper hashes will use the hash you
63           specify here to store the data, and re-create the mapping hash.
64
65       tie(HASH, TIE, [VALUES,] OPTIONS)
66           Tie the HASH with the TIE package which extends Hash::Case.  The
67           OPTIONS differ per implementation: read the manual page for the
68           package you actually use.  The VALUES is a reference to an array
69           containing key-value pairs, or a reference to a hash: they fill the
70           initial hash.
71
72           example:
73
74            my %x;
75            tie %x, 'Hash::Case::Lower';
76            $x{Upper} = 3;
77            print keys %x;       # 'upper'
78
79            my @y = (ABC => 3, DeF => 4);
80            tie %x, 'Hash::Case::Lower', \@y;
81            print keys %x;       # 'abc' 'def'
82
83            my %z = (ABC => 3, DeF => 4);
84            tie %x, 'Hash::Case::Lower', \%z;
85

SEE ALSO

87       This module is part of Hash-Case distribution version 1.05, built on
88       February 06, 2020. Website: http://perl.overmeer.net/CPAN/
89

LICENSE

91       Copyrights 2002-2020 by [Mark Overmeer <markov@cpan.org>]. For other
92       contributors see ChangeLog.
93
94       This program is free software; you can redistribute it and/or modify it
95       under the same terms as Perl itself.  See http://dev.perl.org/licenses/
96
97
98
99perl v5.34.0                      2021-07-22                     Hash::Case(3)
Impressum