my $command = 'cat /etc/passwd'; for my $machine (@machines) { my @output = `ssh '$machine' $command`; ... }