This does not directly answer your question... but
in reply to Telnet using Expect module
From the Expect documentation:
"Are you sure there is no other, easier way? As a rule of thumb, Expect is useful for automating things that expect to talk to a human, where no formal standard applies. For other tasks that do follow a well-defined protocol, there are often better-suited modules that already can handle those protocols. Don't try to do HTTP requests by spawning telnet to port 80, use LWP instead. To automate FTP, take a look at Net::FTP or ncftp (http://www.ncftp.org). You don't use a screwdriver to hammer in your nails either, or do you?"
In this case, you have a well-defined protocol, and the better-suited module would be Net::Telnet. Have you considered using that instead?