BTW, Net::SFTP::Foreign doesn't work reliably under perls prior to 5.8.1 running in HP-UX when password authentication is used due to a bug on this OS.
If this is your case, as a work around, you can replace the IPC::Open3 module that comes with perl 5.8.0 with a later one (version >= 1.0105 required)... though a better solution would be to just upgrade to a newer perl!