Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re^2: Doing an 'ls' in SFTP:Foreign

by StarkRavingCalm (Sexton)
on Feb 15, 2013 at 17:28 UTC ( #1018916=note: print w/replies, xml ) Need Help??

in reply to Re: Doing an 'ls' in SFTP:Foreign
in thread Doing an 'ls' in SFTP:Foreign

Why does this work flawlessly in Net:SFTP but not Net:SFTP:Foreign?

Replies are listed 'Best First'.
Re^3: Doing an 'ls' in SFTP:Foreign
by Illuminatus (Curate) on Feb 15, 2013 at 18:18 UTC
    I haven't used these packages, but the man page for Net::SFTP says ls returns a list of entries, while Net::SFTP::Foreign says it returns a reference to a list of entries.


      Maybe Salvo knows how to format the line to work with Foreign?

        Have you read the documentation to Net::SFTP::Foreign? It's pretty clear. 'ls' returns a reference to a list of entries. Do you know what that means? Do you need to read perlref and/or perlreftut?
Re^3: Doing an 'ls' in SFTP:Foreign
by salva (Abbot) on Feb 16, 2013 at 08:45 UTC
    Different modules, different APIs.

    Retrospectively, having ls return an array reference, was probably a bad idea, bad it is too late to change it now.

      What do you suggest to achieve the same results?
        I suggest realizing that it returns a reference to an array of hashrefs. If you don't know what that is, read the docs that I've already linked to. You must deference the result to achieve the result you desire. There are even examples within this thread of posts somewhere. Example:
        my $result = $sftp->ls(...); foreach my $f (@$result) { ... }
Re^3: Doing an 'ls' in SFTP:Foreign
by runrig (Abbot) on Feb 16, 2013 at 20:16 UTC
    It works flawlessly in both libraries. It just works differently.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1018916]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (8)
As of 2018-06-21 01:53 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (117 votes). Check out past polls.