On 8/24/07, kilaru rajeev <[EMAIL PROTECTED]> wrote:
> Hi Chas,
>
> I was not given the proper arguments to the  *new* function. That is why, it
> was failed to connect. This time I have another trouble. As part of my code,
> I have used the below to statments to list the files in the directory.
>
>  my @ls = $sftp->ls("$srcDir/");
>    print "\n----------------->@ls\n";
>
> But I am not getting the output eventhough the directory got some files
> except "------------------->" part. sometimes I am getting the output as
> below:
>
> ---------------------> HASH(0xd03334) HASH(0xd033dc) HASH(0xd03498)
> HASH(0xd03540) HASH(0xd035e8) HASH(0xd03690) HASH(0xd03738) HASH(0xd037e0)
> HASH(0xd044a4) HASH(0xd0454c) HASH(0xd045f4) HASH(0xd0469c) HASH(0xd04744)
> HASH(0xd047ec) HASH(0xd05da0) HASH(0xd05dac) HASH(0xd05e24) HASH(0xd05e9c)
> HASH(0xd05f50) HASH(0xd0601c) HASH(0xd060c4) HASH(0xd0616c) HASH(0xd06214)
> HASH(0xd062bc) HASH(0xd06364) HASH(0xcdbc20) HASH(0xcdbcc8) HASH(0xcdbd70)
> HASH(0xcdbe18) HASH(0xcdbec0) HASH(0xcdbf68)
>
> I am not sure about the return value of the $sftp->ls(). I thought it will
> return a list as in Net::FTP.  How I should use it? Please help me.

from the docs:
    $sftp->ls($remote [, $subref ])

    Fetches a directory listing of $remote.

    If $subref is specified, for each entry in the directory, $subref will
    be called and given a reference to a hash with three keys: filename,
    the name of the entry in the directory listing; longname, an entry in
    a "long" listing like ls -l; and a, a Net::SFTP::Attributes object,
    which contains the file attributes of the entry (atime, mtime,
    permissions, etc.).

    If $subref is not specified, returns a list of directory entries, each
    of which is a reference to a hash as described in the previous paragraph.

So if you only want the filenames you can say

my @ls = map { $_->{filename} } $sftp->ls($srcDir);

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to