use Net::OpenSSH::Parallel; my $pssh = Net::OpenSSH::Parallel->new; for my $host (keys %$remotehosts) { my $remote = ...; $pssh->add_host($host => "$remote->{user}\@$remote->{host}"); } $pssh->push('*', command => 'test', '-d', $destination); $pssh->push('*', scp_put => $path, $destination); $pssh->run; for my $host (keys %$remotehosts) { $pssh->get_error($host) and print STDERR "Unable to copy file $path to $host" }