in reply to Cant get user input from sockets into variables.

Your problem has to do with newline terminators. The telnet protocol requires that you use CRLF for newlines in both directions, and thus attempting to read a line until a \n (update: the default) will not work, because there will be an extra character (either at the beginning or end, depending on your platform). To fix this you can set $/ to \x0A\x0D (or \012\015 if you prefer, or you may import it from the Socket module with use Socket qw(:crlf) and then use $CRLF for this) so that <$filehandle> will read until CRLF, and so that you can use chomp to take it off the end of the string.

Also note that you should not output \n\r to end lines, because the value of the \n and \r is not portable across platforms. On Windows and UNIX perl it corresponds to NL and CR respectively, but on MacPerl it corresponds to CR and NL respectively. Best off using $CRLF from Socket for clarity, or just enter the hex or octal escapes.

And please use strict and warnings.