in reply to Need help with a simple perl script
I cannot replicate your problem. I am getting almost the desired output. My guess: This might be a cross-platform issue with end-of-line markers. What system are you running the script on? What line endings does your input file use?