Mark Overmeer > Hash-Case-1.02 > Hash::Case

Download:
Hash-Case-1.02.tar.gz

Dependencies

Annotate this POD

Related Modules

Tie::Hash
Tie::CPHash
IO::Scalar
Tie::Hash::Regex
XML::Twig
IO::Stringy
Config::IniHash
Net::Telnet
Win32::GUI
Devel::Symdump
more...
By perlmonks.org

CPAN RT

Open  0
View/Report Bugs
Module Version: 1.02   Source  

NAME ^

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

INHERITANCE ^

 Hash::Case
   is a Tie::StdHash

 Hash::Case is extended by
   Hash::Case::Lower
   Hash::Case::Preserve
   Hash::Case::Upper

SYNOPSIS ^

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

DESCRIPTION ^

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:

METHODS ^

Constructors

$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;

SEE ALSO ^

This module is part of Hash-Case distribution version 1.02, built on March 09, 2012. Website: http://perl.overmeer.net/hash-case/

LICENSE ^

Copyrights 2002-2003,2007-2012 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://www.perl.com/perl/misc/Artistic.html

syntax highlighting: