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;