If you are looking for a module to maniptulate sets, try
Set::Scalar:
use Set::Scalar;
$s = Set::Scalar->new;
$s->insert('a', 'b');
$s->delete('b');
$t = Set::Scalar->new('x', 'y', $z);
$u = $s->union($t);
$i = $s->intersection($t);
$d = $s->difference($t);
$e = $s->symmetric_difference($t);
$v = $s->unique($t);
$c = $s->complement;
From your other post, however, it seems like you are interested in a more specialized form of set, that is integer ranges or spans. In this case, check out the module Set::IntSpan:
use Set::IntSpan qw(grep_set map_set);
$set_spec = "1-20000";
$set = new Set::IntSpan $set_spec;
$set_spec = "1-14192,14194,14196-14221";
$u_set = union $set $set_spec;
$i_set = intersect $set $set_spec;
$x_set = xor $set $set_spec;
$d_set = diff $set $set_spec;
$c_set = complement $set;
For large integral ranges,
Set::IntSpan can be a lot more efficient than
Set::Scalar.