in reply to Web and newlines, aka perl vs ^M

I think that you will have more luck if you indicate ^M as \r, and thus
split(/\r/,...)
and join('\r',...).

Or you could use \xnn form and give it's hexa code.

Update: thanks to Corion:Change the '\r' in the join up there to "\r" - I had a braindead moment - of course the single quotes don't interpolate the backslash notation.