Path: utzoo!attcan!uunet!bfmny0!tneff From: tneff@bfmny0.BFM.COM (Tom Neff) Newsgroups: comp.lang.perl Subject: Re: Best way to nullify an intersection Message-ID: <15631@bfmny0.BFM.COM> Date: 3 Jul 90 10:13:46 GMT References: <601@inpnms.ROCKVILLE.DG.COM> Reply-To: tneff@bfmny0.BFM.COM (Tom Neff) Lines: 30 In article <601@inpnms.ROCKVILLE.DG.COM> logan@rockville.dg.com (James L. Logan) writes: >Is there a better or faster way to drop all elements in set B that >intersect with set A? Here's what I've got so far: ... > foreach $element (@A) { > foreach (@B) { > if (/^$element$/) { > $_ = ''; > last; > } > } > } ... Try this: @B=grep(!do {$x=$_; grep($x eq $_,@A);},@B); >Also, how can I delete the element that was matched in @B, while >also shortening the array by one element; rather than just >setting the element to the null string? Should do it. -- "UNIX should be used :: Tom Neff or as an adjective." -- AT&T :: ...uunet!bfmny0!tneff (UUCP only)