in one array but not in the other

Jay Buffington Jay at Buffington.net
Thu May 18 02:46:42 CDT 2000


I have two arrays (each has a lot of elements which are strings).  I
want to know which items are in array1 but not in array2.

This is the best I could come up with but there is bound to be a better
way:

foreach $element (@array1) { $count{$element} += 2; }
foreach $element (@array2) { $count{$element}++; }
foreach $element (keys %count) { push @array3, $element if
($count{$element} == 1); }

Is there a better way to accomplish this?

Thanks
Jay



More information about the Columbia-pm mailing list