in reply to socket gone crazy

"...but it never seems to come back on the screen inverted."

At first glance, I'd guess the problem is the $/ = CRLF, which is done in the server, but not the client. It might just work if you were to comment that out... You'd have to do that on both ends if you were going to do it at all.

$/ is documented on the perlvar page.

-Paul