Tie::Hash::KeysMask - control key aliasing by mask function, e.g. omit case of character distinction.
SYNOPSIS
use Tie::Hash::KeysMask;
my $mask = sub {...};
tie %argH, 'Tie::Hash::KeyMask',$mask, more arguments;
Yield that the key mask function &$mask translates any key
when applied to %argH like ..
$k => $mask->($k, more arguments)
that is
$argH{$k} expands to $argH{$mask->($k, more arguments)}
$argH{$k} = $v expands to $argH{$mask->($k, more arguments)} = $v
If e.g. choose key mask sub {uc $_[0]} one can access an element without care of case of the key. In place of sub { } particular items can be used which will be translated into a CODE. The translation is
'lc' => sub { lc $_[0] }
'uc' => sub { uc $_[0] }
%M => sub { exists $M{$_[0]} ? $M{$_[0]} : $_[0]}
A class-method codemap manage this translation. If it is pleased one could override it and add ones own translations.
This class inherits from Tie::Hash::Create by which the tied hash can be obtained anonymously as reference with the command
'Tie::Hash::KeyMask'->newHASH (sub {...}, more arguments)
which overrides the tie syntax calling tie from body of newHash.
Product's homepage
Requirements:
· Perl