in reply to Relationships of Matching Sets

Assuming that these are true sets, i.e., no element is repeated within the same set, Set::Scalar has what you need (from the synopsis):
use Set::Scalar; $s = Set::Scalar->new; $s->insert('a', 'b'); $s->delete('b'); $t = Set::Scalar->new('x', 'y', $z);
Given the set objects, you can perfom various operation on the sets to derive relations:
$u = $s->union($t); $i = $s->intersection($t); $d = $s->difference($t); $e = $s->symmetric_difference($t); $v = $s->unique($t); $c = $s->complement;
difference can be used to test for subsets and symmetric difference can be used as a kind of distance metric.

Update: fixed a typo.

-Mark

Replies are listed 'Best First'.
Re^2: Relationships of Matching Sets
by biosysadmin (Deacon) on Dec 17, 2004 at 01:48 UTC
    Great idea, this was the first module that came to my mind. Also, if you'd like to explore your ideas on "close matching," try subclassing Set::Scalar. It seems like it might be difficult to define a general solution for "almost matching" in terms of sets but you could certainly implement specific solutions easily by adding the methods you want to a subclass of Set::Scalar (and leave the union, symmetric_difference, etc. in the original class definition).

    Best of luck. :)