A more robust solution might be to set up port-fowarding on host1 (e.g. on port 8022 -> host2's port 22) so that you can scp "directly" to host2. If this isn't an option, then you can accomplish the same thing with a SSH tunnel -- you can set this up with Net::SSH::Perl and then use Net::SFTP on localhost:8022 to get directly to host2 port 22.