Is there something unusual about how you are calling the script when it doesn't work? What version of perl are you using? I've pasted your examples and it works fine when I run it under NT at version 5.6.0 and under HP-UX 11 at version 5.004_04 - albeit with the data embedded at the end of the script. I know you said that the data is all one line but I once had trouble with output from mail handlers that were adding newlines every 72? characters - when I looked at this on the terminal it was hard to spot because they coincided with where the wrap would naturally occur.