Richard Green wrote:
What would be the quickest , easiest way to remove duplicates from a hash?
Any suggestions are muchly appreciated. Thanks
I assume you mean duplicate values because all keys are unique.
$ perl -le'
use Data::Dumper;
my %hash = qw/ a z b z c x d x e y f g h i /;
print Dumper \%hash;
%hash = reverse %{{ reverse %hash }};
print Dumper \%hash;
'
$VAR1 = {
'e' => 'y',
'c' => 'x',
'h' => 'i',
'a' => 'z',
'b' => 'z',
'd' => 'x',
'f' => 'g'
};
$VAR1 = {
'e' => 'y',
'c' => 'x',
'a' => 'z',
'h' => 'i',
'f' => 'g'
};
John
--
Any intelligent fool can make things bigger and
more complex... It takes a touch of genius -
and a lot of courage to move in the opposite
direction. -- Albert Einstein
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/