Here's my take...
By definition, keys in hashes are always unique. So, if you're after lists of unique things, a hash is what you want. Since you want a unique list inside a hash, you want a hash of hashes. Something like this may do:
use Data::Dumper; my $first_level_key = 1; my @second_level_keys = (2,3,4,5,6,2,7,8); my %hash; $hash{$first_level_key}{$_}++ for @second_level_keys; print Dumper \%hash;
You said you wanted to insert "in order". If order is important, you could sort the keys before processing them if they're numeric, as they were in your example. If you do want strictly ordered hashes, there are modules on CPAN that can do this (disclaimer, I haven't used any of them). Just google for them.
In reply to Re^3: Tie::Hash::MultiValue Unique question
by FunkyMonk
in thread Tie::Hash::MultiValue Unique question
by elsubliminal
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |