in reply to Comparing Two Arrays
my @a = (2,4,6,8,10); my @b = (1,2,3,4,5); my @isect = my @diff = my @union = (); my %count; $count{$_}++ for (@a, @b); @union = keys %count; for (keys %count) { push @{$count{$_} == 2 ? \@isect : \@diff}, $_; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Comparing Two Arrays
by exussum0 (Vicar) on Feb 24, 2005 at 03:45 UTC |