title: Is there a way to remote to a different machine, and run multiple commands there in series (using perl)?
body: <p>I have a Perl script. I want to remote to a different host, and run multiple commands (not 5,10 but 100-150 commands) there. Like,</p>
  <p><strong>Algorithm of Script1.pl (the script on local machine):</strong></p>
  <pre><code>ssh machine10
  // Then execute command1 on machine10
  // Then execute command2 on machine10
  // Then execute command3 on machine10
  .
  .
  .
  // Then execute command100 on machine10, and so on
  
  Then exit, from the remote host.
  Then, run the commands on the local machine.
  </code></pre>
  <p>How can it be implemented?</p>
  <p>I am new to Perl, and after internet browsing, I saw that system command could help [system (ssh remote_host &quot;command1; command2;..&quot;)], but this system command seems not to be feasible as 100-150 commands to run can't be written as such.</p>
  <p>Can anyone please help? <strong>Is there any way like we open an SSH server, and run multiple commands, and then close it?</strong> I am actually looking for such type of technique.</p>
  <p>Thank you!</p>