in reply to Unwanted extra text appearing in array

From the Net::Telnet docs:

    @lines = $t->cmd("who");

which, I think, means you'd better end your subroutine with:

return $telnetsession->cmd('term len 0'); }

update: now that I reread it: no, this won't help.