use Net::SFTP; use Net::SSH::Perl; my $host1 = 'host1'; my $pass1 = 'foo'; # password for host1 my $path1 = '/somepath'; # not really necessary my $host2 = 'host2'; my $pass2 = 'bar'; # password for host1 my $path2 = '/somepath2'; # the actual path which I want to access my $user = 'myname'; # username for host1 and host2 are the same my $home = 'mycode.pl'; my $sftp = Net::SFTP->new($host1, "user" => $user, "password" => $pass1, "debug"=>1) || die 'cannot login $!\n'; $sftp->put($home,$path1)|| die "cannot open: $!";