in reply to using Telnet

$telnet = new Net::Telnet->new( Timeout=>20,Prompt => '/[\$%#>] $/');
I think there's something "new" that shouldn't be there...

Incidentally,

  1. maybe you knew, maybe you didn't: the &-form of sub call shouldn't be used in most cases, nowadays;
  2. I don't know Net::Telnet, but I guess $telnet->open() returns a FH, doesn't it? Then maybe you really want to
    print $output $something;