The problem is that the default for normal open and the default for temfile is different.
in reply to Re^2: Temporary text files with File::Temp
in thread Temporary text files with File::Temp
Teach to always specify the mode of a file, text or binary, because on some platforms it matters. For that matter, be clear about the character encoding too.
Maybe you should update the File::Temp module.
Or, write your own tempfile function that calls the regular open. That way you have consistent semantics. That's what I do.