Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Modifying Script From Net::SFTP to Net::SFTP::Foreign

by hippo (Chancellor)
on Apr 10, 2019 at 18:33 UTC ( #1232415=note: print w/replies, xml ) Need Help??


in reply to Modifying Script From Net::SFTP to Net::SFTP::Foreign

Not a HASH reference at /root/backup/backswitch.pl line 20.
foreach $i ($sftp->ls(".")){ $fname=$i->{filename};

As per the documentation, $sftp->ls returns a reference to a list, not a list.

Replies are listed 'Best First'.
Re^2: Modifying Script From Net::SFTP to Net::SFTP::Foreign
by salva (Abbot) on Apr 10, 2019 at 21:10 UTC
    yes, ls returns a reference in order to be able to signal errors. The usual idiom for using it is as follows:
    my $ls = $sftp->ls(...) or die "ls failed: " . $sftp->error; for my $fn (@$ls) { ... }

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (6)
As of 2020-07-12 09:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?