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 ?
benwilkinsonAsked:
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
0
 
olthoffCommented:
you should be able to do either of the following

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


0
 
malecCommented:
Why not just

for ($ftp->ls) {print "$_\n"}
0
 
ozoCommented:
#or if you already got it as a ref
$ref = $ftp->dir;
for( @{$ref} ){ print "$_\n"}
0
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.