my %hGroups = map { my $sGenes = $hash{$_}; my $hGroupMembers = { map { $_ => 1 } split(',', $sGenes) }; $_ => $hGroupMembers; } keys %hash;