One approach would be to use the Expect module
to launch your telnet session. The whole purpose
of expect is to allow a your program to work interactively
with another program as if it were a user at a terminal.
Also you may want to consider using Net::Telnet.
It has built-in facilities for telnetting into a remote box
and passing the username and password properly.