Tie::Hash::Array - a hash which is internally implemented as a sorted array
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'); }
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.
cmp
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.)
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.
%hash
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.
Martin H. Sluka mailto:perl@sluka.de http://martin.sluka.de/
None known so far.
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
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Tie-Hash-Array
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/Tie-Hash-Array
CPAN Ratings
http://cpanratings.perl.org/d/Tie-Hash-Array
Search CPAN
http://search.cpan.org/dist/Tie-Hash-Array
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.
Tie::Hash::Abbrev
To install Tie::Hash::Array, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Tie::Hash::Array
CPAN shell
perl -MCPAN -e shell install Tie::Hash::Array
For more information on module installation, please visit the detailed CPAN module installation guide.