my %reverse_hash; while ( my ( $key, $value ) = each %hash ) { push @{$reverse_hash{$value}}, $key; }