in reply to Compare two file text input, compare it, replace and write new file
To populate your hash, change
$words{$key} .= exists $words{$key} ? "$val" : $val; [download]
to
$words{$key} = $val; [download]
-- Ken