This works for me (with Perl 5.005 on Win32) if I use STDIN/STDOUT. I don't see anything obviously wrong.
By chance are you putting CLIENT into binmode()? If so, chomp() may be leaving a \r at the end of your input strings, and this might be screwing up your printed presentation.