Using
Expect (or any of the modules relying on it, i.e.
Net::SCP::Expect or
Net::SSH::Expect) is not the best way to automate SSH. Also, network equipment frequently has buggy SSH implementations that can fail in unexpected ways.
Try using a different module as Net::OpenSSH, Net::SSH2, Net::SSH::Perl or Net::SSH::Any.