while () { $key = join ' ',(split / /)[0..3]; if (exists $h{$key}) { print if $_ ne $file1[$h{$key}]; } }