in reply to 2 Hash Tables, 4 Keys...what to do?
I've probably misunderstood some of what you want, but I think the parsing of the keys could be a significant help to you.my %file1; while (<FILE1>) { # Capture first four words, and everything after the next 3 words +(numbers) my ($k1, $k2) = /(\w+(?:\s+\w+){3})(?:\s+\w+){3}(.*)/; # Index by k1, store k2 and line $file1{$k1} = [$k2, $_]; } while (<FILE2>) { my ($k1, $k2) = .... # same regex as before if ($file1{$k1}) { # print file1 line and file2 line print $file1{$k1}->[1]; print; # Check if k2's are equal if ($file1{$k1}->[0] ne $k2) { print "K2's are not equal! (see lines printed above)\n"; } } }
Update: fixed regex as per nobull's note.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: 2 Hash Tables, 4 Keys...what to do?
by nobull (Friar) on Jun 03, 2005 at 16:43 UTC |