SPUG: How can I find @1 - @2?
Chris Wilkes
cwilkes-spug at ladro.com
Wed Jan 24 16:24:25 PST 2007
This might get you started:
perldoc -q intersection
@union = @intersection = @difference = ();
%count = ();
foreach $element (@array1, @array2) { $count{$element}++ }
foreach $element (keys %count) {
push @union, $element;
push @{ $count{$element} > 1 ? \@intersection : \@difference }, $element;
}
On Wed, Jan 24, 2007 at 04:17:55PM -0800, Atom Powers wrote:
> I need to find the difference between two sets of data, two arrays.
>
> I have in @enrolled a list of enrolled students and in @students a
> list of all students. How would I go about finding the contents of
> @students who are not @enrolled?
More information about the spug-list
mailing list