in reply to Matching 2 unordered arrays then printing the first array highlighting the matches?
You create a hash with all elements of array2 as the keys. When iterating through array1, you check whether the elements exists in the hash.
my %match; undef @match{ @array2 }; for (@array1) { print "$_",exists $match{$_}?" match":"","\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Matching 2 unordered arrays then printing the first array highlighting the matches?
by Kenosis (Priest) on Oct 28, 2013 at 19:41 UTC | |
|
Re^2: Matching 2 unordered arrays then printing the first array highlighting the matches?
by Kenosis (Priest) on Oct 28, 2013 at 19:28 UTC |