Stephen Kratzer wrote:
On Friday 24 August 2007 08:57:26 Marian Bednar wrote: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?You cannot use -f. You'll need to stat the file and check the mode.
-f *does* stat the file. The reason that you can't use -f (or stat) is because $_->{filename} is not on a locally mounted file system.
John -- Perl isn't a toolbox, but a small machine shop where you can special-order certain sorts of tools at low cost and in short order. -- Larry Wall -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
