http://qs1969.pair.com?node_id=953628


in reply to Compare two file text input, compare it, replace and write new file

You are splitting your source.txt lines with a single whitespace:
my @words = split / /, $s;

For your code to work, source lines have to look like keys separated by single whitespaces.

Hmm.. it seems like split may not be the right tool, since it's hard to specify what to really split on. Try regex search and replace!
# match a backslash followed by two characters, # then compute the replacement by looking into %words $s =~ s{(\\..)}{ $words{$1} || $1 }ge;

Have a look at perlrequick and perlretut. (And follow kcott's advice.)