# untested %inter = map { $_ => ($hist1{$_} <= $hist2{$_} ? $hist1{$_} : $hist2{$_}) } grep { $hist2{$_} } keys %hist1;