Using ftp within perl

I am not very good at handling references.

when I am using the dir command it returns a reference to a list. How do I actually print that list & / or loop through the list ?
Who is Participating?
KishoreS78Connect With a Mentor Commented:
to a print the list of files in the directory
use $FTp->list([dir])command
to loop thru olthoff has suggested the answer that would work
or u could use
@files = $FTP->ls() if u r in the dirctory where u waanna list or loop thru
you should be able to do either of the following

@files = $FTP->dir();
foreach $File ($FTP->dir()) {};
print $FTP->dir();

Why not just

for ($ftp->ls) {print "$_\n"}
#or if you already got it as a ref
$ref = $ftp->dir;
for( @{$ref} ){ print "$_\n"}
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.