in reply to EXPECT SFTP | Trap Exceptions

The best you can do is to rewrite the script using Net::SFTP::Foreign:
my $sftp = Net::SFTP::Foreign->new($host, user => $user, password => $passwor +d, autodie => 1); if (lc($function) eq 'get) { $sftp->get($file, $dest); } else { $sftp->put($file, $dest); }