For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > August 2007 > Re: Get names of files ONLY using module Net::SFTP::Foreign









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: Get names of files ONLY using module Net::SFTP::Foreign
Salva

2007-08-28, 8:10 am

Chas Owens wrote:

> Be careful, this is Net::SFTP::Foreign, not Net::SFTP.
> They are very similar, but there are differences.


Well, I should know, as I am the module author ;-)


> For instance the ls method
> returns an arrayref, not a list in Net::SFTP::Foreign. This means
> your code should be


oops, you are right!!!

> my @files = @{
> $sftp->ls($remote_dir, wanted => sub { S_ISREG($_[1]->{a}->perm)})
> };


or better:

my $files = $sftp->ls(...)
or die "unable to list remote directory: " . $sftp->error;

print "$_->{filename}\n" for @$files;

after all, error checking is the only reason for "ls" returning an
array ref instead of a list.

Cheers,

- Salva

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com