in reply to 2 Hash Tables, 4 Keys...what to do?
Then run through the other file, matching key and printing if rest isn't equal:for (@file1) { $h{join ' ',(split / /)[0..3]} = $c++; }
You'll want to change the delimiter to something other than spaces, but the following is a working section of code for demonstration purposes:while (<DATA>) { $key = join ' ',(split / /)[0..3]; if (exists $h{$key}) { print if $_ ne $file1[$h{$key}]; } }
use strict; use warnings; my ($c, %h, $key); my @file1 = ( "A B C D E F G\n", "A C B D E F G\n", "D B C A E F G\n", "B B C D E F G\n" ); for (@file1) { $h{join ' ',(split / /)[0..3]} = $c++; } while (<DATA>) { $key = join ' ',(split / /)[0..3]; if (exists $h{$key}) { print if $_ ne $file1[$h{$key}]; } } __DATA__ A B C D E F G A C B D E F H D B C A I F G B B C D E F G
|
|---|