in reply to Re^2: SFTP Foreign Issues using $sftp->ls
in thread SFTP Foreign Issues using $sftp->ls

Actually the module has a glob method:

Yes I know but the title of the OP was about ls() and the OP is using glob style wildcards in a regex in the ls(). I don't feel like rewriting a long convoluted script when the OP needs to try a few simple things and get something working.

And the glob method returns the same style reference to an array of hashes. The OP was incorrectly dereferencing the data structure returned from ls which I pointed out and you did not. Do you think they would do it correctly for glob or find or something else?

  • Comment on Re^3: SFTP Foreign Issues using $sftp->ls

Replies are listed 'Best First'.
Re^4: SFTP Foreign Issues using $sftp->ls
by salva (Canon) on Mar 01, 2016 at 20:14 UTC
    And the glob method returns the same style reference to an array of hashes

    No. glob returns a list.

    The OP was incorrectly dereferencing the data structure

    No. He is already using the names_only feature that makes the method return just the file names instead of hashes.

      No. glob returns a list.

      From the documentation for Net::SFTP::Foreign:glob

      $sftp->glob($pattern, %opts)
      performs a remote glob and returns the list of matching entries in the same format as the "find" method.
      From the documentation for Net::SFTP::Foreign:find
      $sftp->find($path, %opts)
      $sftp->find(\@paths, %opts)
      Does a recursive search over the given directory $path (or directories @path) and returns a list of the entries found or the total number of them on scalar context. Every entry is a reference to a hash with two keys: filename, the full path of the entry; and a, a Net::SFTP::Foreign::Attributes object containing file atime, mtime, permissions and size.

      salva wrote:

      No. He is already using the names_only feature that makes the method return just the file names instead of hashes.
      Good point.

        Does a recursive search over the given directory $path (or directories @path) and returns a list of the entries found

        By default ls returns an array of hashes, glob and find return a list of hashes. When names_only is set, ls returns an array of strings and glob and find return a list of strings.