in reply to Re: Common elements of a hash of hashes
in thread Common elements of a hash of hashes
Almost exactly what I wrote...
How do you like this version? ;-)use strict; use warnings; my %HoH = ( elt1 => { A => "ccc", B => "ccc", C => "ccc", }, elt2 => { A => "ccc", C => "ccc", D => "ccc", B => "ccc", }, elt3 => { A => "ccc", E => "ccc", C => "ccc", }, ); my %count; my $count= scalar keys %HoH; for ( [ grep { $count!=$count{$_} } map { ++$count{$_};$_ } map { keys + %{$HoH{$_}} } keys %HoH ] ) { foreach my $hash (values %HoH) { delete(@$hash{@$_}); } } use Data::Dumper; print Dumper(\%HoH);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Common elements of a hash of hashes
by Perl Mouse (Chaplain) on Oct 07, 2005 at 10:20 UTC |