title: How to get files matching a pattern using perl Net::SFTP::Foreign
body: <p>This is my first submitted question at all and I hope someone can help me with this. I never used perl before so any other tips are highly appreciated too.</p>
  
  <p>Lets say I have a perl script with NET::FTP that matches a pattern which can be specified while calling the script. For example:  </p>
  
  <pre><code>perl ftp.pl '*.txt'
  </code></pre>
  
  <p>To keep it absolute simple, here is what i would do with NET::FTP after establishing the connection to the FTP-Server.</p>
  
  <pre><code>$Pattern = '*.*';
  $ftp-&gt;cwd($FolderAtHost);
  my @Files = $ftp-&gt;ls($Pattern);
  foreach my $File (@Files)
  {
       ...
  }
  </code></pre>
  
  <p>Now I want to make the same thing with NET::SFTP. but the <code>ls</code> Method is completely different. It returns a reference to an Array instead of an array, which is not a big deal.
  But I don't find a way to check for a specific file-pattern like: <strong>*.*</strong></p>
  
  <p>I know there is a <code>wanted =&gt;</code> option in the <code>ls</code> method of the sftp package, but it requires RegEx instead of a file-pattern.</p>
  
  <pre><code>sftp-&gt;setcwd($FolderAtHost)
  my @FilesRef = $sftp-&gt;ls(names_only =&gt; 1, wanted =&gt; qr/.../);
  foreach my $File (@$FilesRef)
  {
      ...
  }
  </code></pre>
  
  <p>Do I have to write a File-Pattern to Regex converter first or is there a simpler way to achieve this?
  Maybe matching the filename within the <code>foreach</code>?</p>