First of all you didn't mention whether you can run the commands
through a normal telnet client on the machine you are running the program.
Then make sure you are not forgetting to send any characters eg \r ands \n, these are neccessary
at the end of lines to send the buffer.
You might also like to try
IO::Socket, instead of using direct socket calls.
This module is part of the standard distribution and provides an OO and to many a
more intuitive and simpler interface to sockets.