(Revised per mdillon's note, but in a different way for speed)my %revhash; while (my ($key, $value) = each %hash) { push @{$revhash{$value}}, $key; } for (sort keys %revhash) { print "$_ => @{$revhash{$_}}\n"; }
In reply to Inverting a hash to get all keys for this value by merlyn
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |