in reply to comparing arrays
The interesting thing about my solution is that it returns dupe counts, so you could theoretically even sort dupes by the number of times they appear.
use strict; use warnings; my @array1 = qw(13470660 13471850 14028274 14028286); my @array2 = qw(14028145 14028286 13476691 13471850); my (%keys, $key, @dupes); for (0..$#array1) { if ($array1[$_] < $array2[$_]) { $key = "$array1[$_] $array2[$_]"; + } else { $key = "$array2[$_] $array1[$_]"; } if ($keys{$key}++ == 1) { splice(@array1, $_, 1); splice(@array2, $_, 1); push(@dupes, $key); } } for (0..$#array1) { print "$array2[$_] $array1[$_]\n"; } print "\n$_ ".($keys{$_}-1) for (@dupes);
|
|---|