Hi all,
I am a newbie in this forum and Perl too ;-)
I am trying writing script transfering files using module
Net::SFTP::Foreign.
I need to retrieve from remote directory only names of files (not
directories, links,etc.).
Something like this doesn't work:
--------------
use strict;
use warnings;
use Net::SFTP::Foreign;
my $remote_dir = "/tmp";
my $sftp = Net::SFTP::Foreign->new("host");
$sftp->error and print "SSH connection failed: " . $sftp->error . "\n";
$sftp->setcwd($remote_dir);
my $DH = $sftp->opendir($remote_dir);
while ($_ = $sftp->readdir($DH)) {
print "$_->{filename} \n" if -f $_->{filename};
}
---------------
Script above write out nothing, but if last line is this
print "$_->{filename} \n";
It writes out names of files, directories, but I need only names of files.
How can I get it easy?
Thanks.
Marian