in reply to comparing two files for duplicate entries
I don't know how well it would scale, but I'd build a hash from the first file ($objects{'object1'}=23.12;), then scan the second file. If the object in the second file has a defined hash, then print out the hashkey and both values..
Untested code... and I'm assuming a space delim. as per your examples..
open(FILE, "file1"); while(<FILE>){ if(/(\S+)\s+(\S+)/){ $hash{$1} = $2; } } close FILE; open(FILE, "file2"); while(<FILE>){ if(/(\S+)\s+(\S+)/){ print "$1: $hash{$1} $2\n" if defined $hash{$1}; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: comparing two files for duplicate entries
by Fletch (Bishop) on Sep 27, 2006 at 16:50 UTC | |
|
Re^2: comparing two files for duplicate entries
by mk. (Friar) on Sep 27, 2006 at 16:54 UTC |