title: How can I pause Perl processing without hard-coding the duration?
body: <p>I have a Perl script that contains this code snippet, which calls the system shell to get some files by SFTP and unzip them with WinZip:</p>
  
  <pre><code>#  Run script to get files from remote server
  system "exec_SFTP.vbs";
  
  #  Unzip any files that were retrieved
  foreach $zipFile (&lt;*.zip&gt;) {
      system "wzunzip $zipFile";
  }
  </code></pre>
  
  <p>Even if some files are retrieved, they are never unzipped, because by the time the files are retrieved and the SFTP connection is closed, the Perl script has already completed the unzip step, with the result that it doesn't find anything to unzip.</p>
  
  <p>My short-term fix is to insert</p>
  
  <pre><code>sleep(60);
  </code></pre>
  
  <p>before the unzip step, but that assumes that the SFTP connection will finish within 60 seconds, which may sometimes be a gross over-estimate, and other times an under-estimate.</p>
  
  <p>Is there a more sound way to cause Perl to pause until the SFTP connection is closed before proceeding with the unzip step?</p>
  
  <p>Edit:  Responders have questioned (and reasonably so) the use of a VB script rather than having Perl do the file transfer.  It has to do with security -- the VB script is maintained by others and is authorized to do the SFTP.</p>