my $command = "ssh $machine 'tail -f /var/log/2001-log'"; open(REMOTE, "$command |") or die "Can't run \"$command\": $!"; while (my $line = ) { ... }