Uh, why are you using expect? It explictly says in it's docs to not use it for things that other modules already exist for, in this case Net::Telnet which will create a connection and let you do anything you want with it.
Comment on Re: writing to an object (telnet session) using expect