You're going to have a problem doing this since your CGIs are going to be run each as a separate process. Therefore, between requests, your telnet object is being serialized to disk, but the socket will be closed when the application exists. Therefore, the second request no longer refers to an active socket.
There are a number of work-arounds, though. You could run your scripts inside of mod_perl and save your telnet information in memeory to keep the socket alive between requests. Another solution would be to have a separate process running as a sort of middleware to actually manage the telnet connection and then use IPC to tell the persistent script what to do--a named pipe could work well here.