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.
In Section
Seekers of Perl Wisdom