in reply to Moving folders using FTP

You could always FTP each file in the directory which would leave you with the same result - i.e the whole directory contents will have been transferred.
opendir (DIR, $some_dir) || die "opendir: $!\n"; for my $file_found (readdir DIR) { my $full_path = $some_dir . "/" . $file_found; next if (-d $full_path); $ftp->put($full_path) || die "put: $!\n"; }
-- vek --

Replies are listed 'Best First'.
Re: Re: Moving folders using FTP
by data64 (Chaplain) on Apr 06, 2003 at 17:54 UTC

    This would not get any sub-directories. I would replace the calls to opendir,readdir with a call to File::Find


    Just a tongue-tied, twisted, earth-bound misfit. -- Pink Floyd

      This would not get any sub-directories.

      Right, but I didn't see that as a requirement from the OP.

      I would replace calls to opendir,readdir with a call to File::Find

      This is an interesting point because I've never needed to use File::Find before. Just out of curiosity, why is File::Find better than Perl's own opendir & readdir?

      Update: Should have phrased the question slightly better. I meant to ask why File::Find would be better than opendir & readdir for reading files from a directory bearing in mind that recursing through a directory was not a requirement.

      -- vek --

        It's not better. It's something else. readdir() gives you the files in a single directory. File::Find gives you all files in a tree.

        If the question was "why is File::Find better than recursing through the directory tree oneself using opendir() and readdir()" ... I'd say ... because it's well tested and maintained. You may reinvent the wheel if you feel like it I don't find it necessary.

        Jenda
        Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.
           -- Rick Osborne

        Edit by castaway: Closed small tag in signature