Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

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

by hippo (Bishop)
on Apr 10, 2019 at 18:33 UTC ( [id://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 (Canon) 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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1232415]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (5)
As of 2024-04-25 12:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found