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);

$\=~s;s*.*;q^|D9JYJ^^qq^\//\\\///^;ex;print

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

    How do you like this version?

    Not obscure enough for obfuscated code, and too obscure for normal code. I never liked for (SCALAR) {... $_ ...} as an alternative for {my $var = SCALAR; ... $var ...}.

    Perl --((8:>*