in reply to multiple matching in arrays
This will give you one each of the matches. They wont be in the same order as they were found, however. If that's important, then you have to addforeach 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;
inside the loop, instead of doing keys() at the end to load up @save.push(@save, $found) if !exists $found_one{$found}; $found_one{$found} = 1;
Also, as liverpole notes, you have a typo in the assignments for the sample arrays, where you use square brackets instead of parens. The way it's written the code won't work.
|
|---|