in reply to comparing arrays

This will keep the first pair found.

my %lookup; my @to_keep; foreach (0..$#array1) { my $a1 = $array1[$_]; my $a2 = $array2[$_]; next if $lookup{$a1}; next if $lookup{$a2}; $lookup{$a1} = $lookup{$a2} = 1; push(@to_keep, $_); } @array1 = @array1[@to_keep]; @array2 = @array2[@to_keep];

The above will yield "interesting" results for