Array subtraction, like sets

From: Robin Sheat (robin_at_kallisti.net.nz)
Date: 01/30/04


Date: Fri, 30 Jan 2004 18:05:55 +1300
To: beginners@perl.org


Hey there, what is a nice way of doing what this looks like it should
do:

@a=([1,2,3],[5,5,5],[9,8,7]);
@b=([5,5,5],[1,2,3]);
@c=@a-@b;

and have @c == ([1,2,3]);

Is there a good way of doing this? (I've tried the obvious things on the
command line, to no avail). I could probably write a function for it
without too much trouble, but it could get ugly :)

cheers,

-- 
Robin <robin@kallisti.net.nz>                 JabberID: <eythian@jabber.org>
Hostes alienigeni me abduxerunt. Qui annus est?
PGP Key 0x776DB663 Fingerprint=DD10 5C62 1E29 A385 9866 0853 CD38 E07A 776D B663




Relevant Pages