http://qs321.pair.com?node_id=1060051


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