perlvroom has asked for the wisdom of the Perl Monks concerning the following question:

my $directory='C:/Temp'; mkdir($directory); chdir($directory); my $ftp = Net::FTP::Recursive->new("$ftp1", Debug => 0); $ftp->login("$login",'$password'); $ftp->cwd('/'); $ftp->rget(); $ftp->quit; my $ftp2 = Net::FTP::Recursive->new("$ftp2", Debug => 0); $ftp2->login("$login",''); $ftp2->cwd('/'); $ftp2->rput(); $ftp2->quit; chdir("C:/"); remove_tree($directory);
The above script will copy the contents of a directory on one ftp server and move it to another. Is there any way i can make it to where it will only copy the directory tree and ignore any files in any of the folders?

Replies are listed 'Best First'.
Re: copying FTP directories from one server to another
by hippo (Archbishop) on Jun 08, 2013 at 09:45 UTC

    I have never used Net::FTP::Recursive, but the documentation says:

    This module's default behavior is such that the remote ftp server should understand the "dir" command and return UNIX-style directory listings. If you'd like to provide your own function for parsing the data retrieved from this command (in case the ftp server does not understand the "dir" command), all you need do is provide a function to one of the Recursive method calls. This function will take the output from the "dir" command (as a list of lines) and should return a list of Net::FTP::Recursive::File objects.

    So, it seems to me that you could use ParseSub => \&foo and construct your foo such that it only returns directories in the list.