in reply to Net-SFTP-Foreign not reading /etc/hosts file?

Net::SFTP::Foreign (usually) just uses the binary ssh command from your system and, unless you have some really rare configuration, it honors /etc/hosts.

Anyway, set debugging on for Net::SFTP::Foreign adding the following line at the beginning of your script:

$Net::SFTP::Foreign::debug = -1;
... and then run it and post here the debugging output.

There should be a line indicating how ssh is called, similar to ...

#18146 1442165394.00000 _init_transport: ssh cmd: ssh -o NumberOfPassw +ordPrompts=1 -o PreferredAuthentications=keyboard-interactive,passwor +d foo.bar.com -s sftp
You can also try running that command but without the -s sftp part, at the shell. Does it work? if it doesn't you should start by figuring out why not.

Finally, if you want compatibility with Net::SFTP, you should go for Net::SFTP::Foreign::Compat instead of Net::SFTP::Foreign.