NAME
Tie::Hash::Array - a hash which is internally implemented as a sorted array
SYNOPSIS
use Tie::Hash::Array;
tie my %hash, 'Tie::Hash::Array';
$hash{foo} = 'bar';
my $object = new Foo;
$hash{$object} = 'You can also use objects as keys.';
while ( my($key, $value) = each %hash ) {
$key->dwim($value) if ref $key && $key->can('dwim');
}
DESCRIPTION
Hashes tied to this class will interally be stored as an array alternately containing keys and values, with its keys sorted in standard string comparison order, that is, as cmp
does.
While the main purpose of this module is serving as a base class for Tie::Hash::Abbrev, some of its side effects may also be useful by themselves:
"each" in perlfunc will return the contents in sorted order.
You can use objects as keys. (Please note, however, that in this case the string representations of these objects should stay constant, or to be exact, their string sorting order should maintain stable, or else you might get undesired results.)
ADDITIONAL METHODS
split_at
my %smaller = tied(%hash)->split_at('foo');
will delete all keys from %hash
which are asciibetically smaller than "foo" (which needs not exist as a key itself) and return a list of the deleted keys and values.
SUBCLASSING
Please do not rely on the implementation details of this class for now, since they may still be subject to change.
If you'd like to subclass this module, please let me know; perhaps we can agree on some standards then.
AUTHOR
Martin H. Sluka
mailto:perl@sluka.de
http://martin.sluka.de/
BUGS
None known so far.
SUPPORT
You can find documentation for this module with the perldoc command.
perldoc Tie::Hash::Array
You can also look for information at:
RT: CPAN's request tracker
AnnoCPAN: Annotated CPAN documentation
CPAN Ratings
Search CPAN
COPYRIGHT & LICENCE
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
The full text of the license can be found in the LICENSE file included with this module.