title: Perl sFTP : how to check remote file doesnt exist
body: <p>I am 1 day old to Perl, was going through <a href="https://metacpan.org/pod/Net::SFTP::Foreign" rel="nofollow">API doc here</a>, have few basic questions</p>
  
  <pre><code>  $sftp = Net::SFTP::Foreign-&gt;new($host, autodie =&gt; 1);
    my $ls = $sftp-&gt;ls("/bar");
    # dies as: "Couldn't open remote dir '/bar': No such file"
  </code></pre>
  
  <p><strong>Question</strong></p>
  
  <ul>
  <li>with autodie will the connection be auto closed ?</li>
  <li>we see in above example how to use folder , similar syntax also works for file ?</li>
  </ul>
  
  <p>Or something like this makes more sense ??</p>
  
  <pre><code>  my $sftp = Net::SFTP::Foreign-&gt;new($host, autodie =&gt; 1);
    $sftp-&gt;find("/sdfjkalshfl", # nonexistent directory
                on_error =&gt; sub { print "foo!\n";sftp-&gt;disconnect();exit; });
  </code></pre>
  
  <p>I was trying to run following code on my windows machine</p>
  
  <pre><code>use Net::SFTP::Foreign;
  my $host = "demo.wftpserver.com";
  my $sftp = Net::SFTP::Foreign-&gt;new($host ,ssh_cmd =&gt; 'plink',autodie =&gt; 1);
  my $ls = $sftp-&gt;ls("/bar");
  </code></pre>
  
  <p>But i get error </p>
  
  <blockquote>
    <p>'plink' is not recognized as an internal or external command ,</p>
  </blockquote>
  
  <p>however when i run plink from windows command line it works fine !!</p>