ssh account@remote.machine.intern -c 'perl -w whatever.pl'
If you want to launch that from Perl, the following could work on both, Windows and Linux, presuming you have passwordless keys and/or ssh-agent running to handle the authentication:
use strict;
my @machines = qw( worker1 worker2 worker3 );
my @cmd = @ARGV;
my $ssh = 'ssh';
for my $machine (@machines) {
my @commandline = $ssh, $machine, '-c', @cmd;
print "[$machine] @commandline\n";
system(@commandline) == 0
or warn "Couldn't launch >>@cmd<< on $machine: $! / $?";
};
The above will wait for each task on each machine to finish. If you do want to run all tasks in parallel, you will have to spawn the processes differently, depending on how your OS lets you spawn processes in parallel. On Windows, use system( 1, ...) or system('start',...), and on Unixish shells, you can likely use the "background operator" &:
...
# Linux parallel, watch out for quoting with your shell!
system("@commandline &") == 0
...
Windows is nicer here but has the drawback that you can only run 63 processes that way in parallel unless you compile your own Perl:
...
# Windows parallel, watch out for quoting with your shell!
system(1, @commandline) == 0
...
|