my $files = $ftp->ls(); # this returns an arrayref for my $filename (@$files) { # put your code in here to deal with each file }