foreach my $found (@array2) { if (&match_names($item,$found)) { print "found a match ($item = $found\n"; $found_one{$found} = 1; # *** changed line } # end-if } # end-foreach } # end-foreach @save = keys %found_one; #### push(@save, $found) if !exists $found_one{$found}; $found_one{$found} = 1;