GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Hash::Case(3) User Contributed Perl Documentation Hash::Case(3)

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:

  • Hash::Case::Lower (native hash)

    Keys are always considered lower case. The internals of this module translate any incoming key to lower case before it is used.

  • Hash::Case::Upper (native hash)

    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.

  • Hash::Case::Preserve

    The actual casing is ignored, but not forgotten.

$obj->addHashData(HASH)
Add the data of a hash (passed as reference) to the created tied hash. The existing values in the hash remain, the keys are adapted to the needs of the the casing.
$obj->addPairs(PAIRS)
Specify an even length list of alternating key and value to be stored in the hash.
$obj->setHash(HASH)
The functionality differs for native and wrapper hashes. For native hashes, this is the same as first clearing the hash, and then a call to addHashData(). Wrapper hashes will use the hash you specify here to store the data, and re-create the mapping hash.
tie(HASH, TIE, [VALUES,] OPTIONS)
Tie the HASH with the TIE package which extends Hash::Case. The OPTIONS differ per implementation: read the manual page for the package you actually use. The VALUES is a reference to an array containing key-value pairs, or a reference to a hash: they fill the initial hash.

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.03, built on January 22, 2018. Website: http://perl.overmeer.net/CPAN/

Copyrights 2002-2018 by [Mark Overmeer]. 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/

2018-01-22 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.