jpearl has asked for the wisdom of the Perl Monks concerning the following question:
Any help would be greatly appreciated! Oh, I've also taken a look at Hash::Merge, but it seems to break with some message about odd numbers of elements... I could be using it incorrectly however (I'm still pretty new to perl)#Handle the case of overlapping groups $groupID = 1; my %groupSeen; foreach my $group1 (keys %groupOfBact){ foreach my $group2 (keys %groupOfBact){ if ($group1 != $group2){ foreach my $strain (keys %{$groupOfBact{$group1}}){ if((exists $groupOfBact{$group2}{$strain})&&(!exists $ +groupSeen{$strain})){ %{$updatedGroupHash{$groupID}} = (%{$groupOfBact{$ +group1}}, %{$groupOfBact{$group2}}); foreach my $seen (keys %{$updatedGroupHash{$groupI +D}} ){ $groupSeen{$seen}=1; } $groupID++; last; } else { %{$updatedGroupHash{$groupID}} = %{$groupOfBact{$g +roup1}}; } } } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Merging Complex Hashes
by ig (Vicar) on Mar 11, 2009 at 19:43 UTC | |
by jpearl (Scribe) on Mar 11, 2009 at 20:39 UTC | |
by ig (Vicar) on Mar 11, 2009 at 20:57 UTC | |
by jpearl (Scribe) on Mar 11, 2009 at 21:54 UTC | |
|
Re: Merging Complex Hashes
by ikegami (Patriarch) on Mar 11, 2009 at 19:04 UTC | |
by jpearl (Scribe) on Mar 11, 2009 at 19:29 UTC | |
|
Re: Merging Complex Hashes
by moritz (Cardinal) on Mar 11, 2009 at 18:42 UTC | |
|
Re: Merging Complex Hashes
by MaskedMarauder (Acolyte) on Mar 11, 2009 at 18:50 UTC |