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: $! / $?"; };