@a = qw/5 7 2 5 1 3/; undef @{$h{a}}{5, 4, 3}; undef @{$h{b}}{7, 9, 6}; undef @{$h{c}}{0, 2, 1}; for $x (@a){ exists $h{$_}{$x} and print "$x pool $_\n" for keys %h; }