in reply to Matching 2 unordered arrays then printing the first array highlighting the matches?

Dear DT --

First method (non-Perl):

  1. sort fileA and write it to /tmp
  2. sort fileB and write it to /tmp
  3. Use cmp or diff to detect the differences between the two /tmp files and report.
Second Method (using Perl):
  1. read fileA and use each value as a hash-key with a hash-value of 1 ($seen_hash{$valueA} = 1;)
  2. read fileB and use each value as a hash-key and add a value of 2 ($seen_hash{$valueB} += 2;)
  3. Read through the hash and report on all keys where the value is '3'.

----
I Go Back to Sleep, Now.

OGB

  • Comment on Re: Matching 2 unordered arrays then printing the first array highlighting the matches?
  • Select or Download Code

Replies are listed 'Best First'.
Re^2: Matching 2 unordered arrays then printing the first array highlighting the matches?
by hdb (Monsignor) on Oct 28, 2013 at 21:19 UTC

    What happens if there are duplicates in fileB?