in reply to File I/O while using Sockets?

If your $_ comparison doesn't work, that usually indicates that it doesn't hold what you expect.
print $client "Thank you for your command: ->$_<-\n"; print OUT "->$_<-\n";
In my testing, I saw some spurious \r (carriage return) characters -- that may have been due to my use of a telnet client. A simple tr/\r//d; before the chomp fixed it for me.