C:\>perldoc -q intersection
Found in C:\Perl\lib\pod\perlfaq4.pod
  How do I compute the difference of two arrays?  How do I compute the
intersect
ion of two arrays?

            Use a hash. Here's code to do both and more. It assumes that
            each element is unique in a given array:

                @union = @intersection = @difference = ();
                %count = ();
                foreach $element (@array1, @array2) { $count{$element}++
}
                foreach $element (keys %count) {
                    push @union, $element;
                    push @{ $count{$element} > 1 ? \@intersection :
\@difference
 }, $element;
                }

            Note that this is the *symmetric difference*, that is, all
            elements in either A or in B but not in both. Think of it as
an
            xor operation.


C:\>

> -----Original Message-----
> From: Bob Williams [mailto:[EMAIL PROTECTED]] 
> Sent: Thursday, January 09, 2003 2:02 PM
> To: [EMAIL PROTECTED]
> Subject: Comparing Apples and Oranges
> 
> 
> I have two lists.
> 
> List 1 is the control list containing: Apple, Orange, Lemon, 
> Tangerine, and Grape. 
> List 2 contains Apple, Tangerine, Grape, and Banana.
> 
> I need a script that compares the two lists and will 
> eliminate banana from list 2 because banana is not in the 
> control List 1. The script will not add Orange to List 2 even 
> tho it is in the Control List 1. 
> 
> Perhaps the script would create list 3 with the results 
> (Apple, Tangerine, and Grape)?
> 
> Thanks
> 
> Bob Williams
> 


**** DISCLAIMER ****

"This e-mail and any attachment thereto may contain information which is confidential 
and/or protected by intellectual property rights and are intended for the sole use of 
the recipient(s) named above. 
Any use of the information contained herein (including, but not limited to, total or 
partial reproduction, communication or distribution in any form) by other persons than 
the designated recipient(s) is prohibited. 
If you have received this e-mail in error, please notify the sender either by 
telephone or by e-mail and delete the material from any computer".

Thank you for your cooperation.

For further information about Proximus mobile phone services please see our website at 
http://www.proximus.be or refer to any Proximus agent.


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to