Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^3: Doing an 'ls' in SFTP:Foreign

by salva (Monsignor)
on Feb 21, 2013 at 09:13 UTC ( #1019923=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Doing an 'ls' in SFTP:Foreign
in thread Doing an 'ls' in SFTP:Foreign

Just loop over the returned values generating a new list with the fields you want to keep:

my $ls = $sftp->ls('/home/ftptest/inbound', no_wanted => qr/^\./ ); my @names_and_sizes = map { { filename => $_->{filename}, size => $_-> +{a}->size } } @$ls; # or... my %size = map { $_->{filename} => $_->{a}->size } @$ls;


Comment on Re^3: Doing an 'ls' in SFTP:Foreign
Download Code
Re^4: Doing an 'ls' in SFTP:Foreign
by StarkRavingCalm (Sexton) on Feb 21, 2013 at 15:05 UTC

    Perfect!

    $VAR1 = { 'text.txt' => 0, '1.1' => 0, 'newfile' => 171, 'upfile1' => 0, 'newfile3' => 171, 'upfile2' => 0, 'upfile3' => 0, 'upfile4' => 312, 'slkdjslkd.lkjlsdfsdl' => 0, 'newfile2' => 171 };

    Thanks Salva!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1019923]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (6)
As of 2014-10-20 05:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (72 votes), past polls