use warnings; use strict; use Net::SFTP::Foreign; my $host = 'localhost'; my $list_file = 'files.txt'; my $sftp = Net::SFTP::Foreign->new($host); # look in my scratch working directory my @list = $sftp->find('scratch'); open my $wfh, '>', $list_file or die $!; print $wfh "$_->{filename}\n" for @list; #### scratch scratch/sftp.pl scratch/dt.pl scratch/time.pl scratch/auth.pl scratch/or.pl scratch/test scratch/test/a.txt