in reply to comparing arrays

How large are the arrays going to be, and how often / how many dupes are there likely to be? My solution below assumes that the arrays are fairly small and won't suffer much from being modified in place. I'm also assuming that you only have pairs (both arrays same length, no missing array cells).

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);