Hash::Case(3pm) | User Contributed Perl Documentation | Hash::Case(3pm) |
Hash::Case - base class for hashes with key-casing requirements
Hash::Case is a Tie::StdHash Hash::Case is extended by Hash::Case::Lower Hash::Case::Preserve Hash::Case::Upper
use Hash::Case::Lower; tie my(%lchash), 'Hash::Case::Lower'; $lchash{StraNGeKeY} = 3; print keys %lchash; # strangekey
Hash::Case is the base class for various classes which tie special treatment for the casing of keys. Be aware of the differences in implementation: "Lower" and "Upper" are tied native hashes: these hashes have no need for hidden fields or other assisting data structured. A case "Preserve" hash will actually create three hashes.
The following strategies are implemented:
Keys are always considered lower case. The internals of this module translate any incoming key to lower case before it is used.
Like the ::Lower, but then all keys are always translated into upper case. This module can be of use for some databases, which do translate everything to capitals as well. To avoid confusion, you may want to have you own internal Perl hash do this as well.
The actual casing is ignored, but not forgotten.
example:
my %x; tie %x, 'Hash::Case::Lower'; $x{Upper} = 3; print keys %x; # 'upper' my @y = (ABC => 3, DeF => 4); tie %x, 'Hash::Case::Lower', \@y; print keys %x; # 'abc' 'def' my %z = (ABC => 3, DeF => 4); tie %x, 'Hash::Case::Lower', \%z;
This module is part of Hash-Case distribution version 1.05, built on February 06, 2020. Website: http://perl.overmeer.net/CPAN/
Copyrights 2002-2020 by [Mark Overmeer <markov@cpan.org>]. For other contributors see ChangeLog.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See http://dev.perl.org/licenses/
2022-10-13 | perl v5.36.0 |