Dear Monks,
I am failing to get list of files from following code
use strict;
use lib '/myperllib';
use Net::SFTP::Foreign;
my $host="root\@10.111.11.11";
my $password="password";
my $sftp = Net::SFTP::Foreign->new($host, fs_encoding => 'latin1');
my @ls = map { $_->{filename} } $sftp->ls('/root/mydirs');
foreach my $myfile (@ls)
{
print "File: $myfile\n";
}
I am Not able to understand the error
Not a HASH reference at xx.pl line 7.. Also I am touching Perl code after two years and it seems I have lost the touch (Feels great to work on it again :-)). Can someone help me please ?
Update:I got the answer from some other thread. This code works fine as per thread
Doing an 'ls' in SFTP:Foreign
my $ls = $sftp->ls('/root/mydirs', no_wanted => qr/^\./ );
my %size = map { $_->{filename} => $_->{a}->size } @$ls;
foreach my $filename (sort keys %size) {
print "$filename : $size{$filename}\n";
}