#!/usr/bin/perl-w use strict; use warnings; use open ':utf8'; use autodie; #open FILE B open (FALSEFRIENDINPUT, ") { #chomp off the new line chomp $line; # split the line on tab my ($filebkeys, $filebvalues) = split /\t/, $line; $fileb{$filebkeys} = $filebvalues; #open output files open (OUTPUT1, ">OutputMatchedFalseFriends.txt"); open (OUTPUT2, ">OutputNonMatchedWords.txt"); #open FILE A open (BILINGUALWL, " ) { chomp $line; #split the line on tab my ($fileakeys, $fileavalues) = split /\t/, $line; #do first columns match? if ($fileb{$fileakeys}) { #does the second column value contain the other as a substring? if ($fileb{$fileakeys} =~ /$fileavalues/ or $fileavalues =~ /$fileb{$fileakeys}/) { #if yes, print it to OutputMatchedFalseFriends.txt print OUTPUT1 "$line\n"; #loop to the next line next; } } else { #if not, print it to OutputNonMatchedWords.txt print OUTPUT2 "$line\n"; } } }