in reply to Re^3: inverting hash / grouping values
in thread inverting hash / grouping values
...but maybe I was not still not clear enough! ;-)
I'd rather prefer a solution better (readable | self documenting | maintainable) then
DB<140> \%h => { a => 1, b => 2, c => 1, d => 2, e => 3 } DB<141> push @{ $h2{$h{$_}} }, $_ for keys %h => "" DB<142> \%h2 => { 1 => ["c", "a"], 2 => ["b", "d"], 3 => ["e"] }
so not necessarily a complicated solution only relying on List::Util or List::MoreUtils ...
BUT I know that you love this kind of games ... ;D
Cheers Rolf
( addicted to the Perl Programming Language)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: inverting hash / grouping values
by hdb (Monsignor) on Sep 28, 2013 at 08:26 UTC | |
by LanX (Saint) on Sep 28, 2013 at 11:34 UTC |