⭐ in reply to set theory w/hashes? arrays? done quickly?
In addition, see the Set::Scalar module, which is specifically designed to do manipulations and tests with sets. In a pinch, though, some code like this might help you (taken directly from the cookbook):
If you need the difference:foreach $e (@a, @b) { $union{$e}++ && $isect{$e}++ } @union = keys %union; @isect = keys %isect;
Set::Scalar makes this much more straightforward:@diff = (); foreach $e (keys %union) { push(@diff, $e) unless $isect{$e}; }
$s = new Set::Scalar (keys %hash1); $t = new Set::Scalar (keys %hash2); @isect = $s->intersection($t)->members;
|
|---|