Thanks to all for your help! Adding binmode(outputfile) solved my immediate problems.
in reply to end of line help
I am not sure if the file meets your definitions of binary, as it does have line endings. In a text editor the first few lines are readable, then a few thousand lines of jibberish. And just to clarify, the 'binary' files are not tab delimited, the first infile reads a spreadsheet with the original and replacement values.
I commented the strict because it gave me too many errors and the easiest solution I could find was to turn it off. I know the logic there is terrible and as I have time will try to learn the correct syntax.