http://www.perlmonks.org?node_id=662516


in reply to help with Net::SFTP

First point: your code and errors don't match up. The "used only once" errors indicate that you are using "use strict", but your posted code doesn't show that.

To get help effectively, there can be no mismatch between your code and the errors!

Here's what you need to do: use "my" to fix your errors, don't drop "use strict", for example:

use strict; use warnings; use Net::SFTP; my $SFTPSite = 'sftp.xxxxbroker' ; my $userid = 'fred'; my $pword = 'bedrock'; #** ** ** ** ** ** ** ** # Setup to do the SFTP my $sftp = Net::SFTP->new( $SFTPSite, $userid, $pword ) or die "Could NOT create SFTP " ; #Net::SFTP const +ructor my @entries = $sftp->ls('/'); # slurp all entries into an array foreach $entry (@entries) { print "$entry \n"; chomp $entry; my @fields = split /\s+/, $entry; print "the file name: " . $fields[-1] . "\n"; }

Then post your complete code, preferably boiled down to the smallest working portion that demonstrates your problem.