in reply to How to extract keyvalue pairs with duplicate values

Well Mister merlyn was faster ...
anyway:
use strict; my %hash = ( 1 => 'a' , 2 => 'b' , 3 => 'c' , 4 => 'b' , 5 => 'e' , 6 => 'b' , 7 => 'a' , 8 => 'z' ); my %values_with_multiple_keys = (); foreach my $k (keys %hash) { push @{ $values_with_multiple_keys{$hash{$k}} }, $k; } foreach my $m (keys %values_with_multiple_keys) { if (scalar @{$values_with_multiple_keys{$m}} > 1) { print "$m is referenced by: ", join ', ', @{$values_with_multi +ple_keys{$m}}, "\n"; } } ___OUTPUT___ a is referenced by: 7, 1, b is referenced by: 6, 2, 4,

pelagic

Replies are listed 'Best First'.
Re^2: How to extract keyvalue pairs with duplicate values
by august3 (Acolyte) on Oct 18, 2004 at 23:52 UTC
    Hi everybody Thanks for helping me. Augustine
      Hello Augustine!
      it's now 3 weeks ago but you are very welcome anyway!

      pelagic