⭐ in reply to Union of Two Hashes
For large:%union = (%first, %second);
(makes sense once you consider the memory usage for the first snippet.while (($k,$v) = each %first) { $union{$k} = $v; } while (($k,$v) = each %second) { $union{$k} = $v; }
For intersection, all you really need to do is change $matchWords to $matchWords{$k}++ the iterate of then matchWords looking for values == 2
|
---|