in reply to Net::FTP Mget

did you mean this?
my @lines = $ftp->dir or die "cannot list dir contents\n";
Also, won't $file2 =~ s/^(.+ )(.+?)$/$2/; break for files with spaces in them?

I think it would also be more useful to have it support a regex to check $file2 against so that it can handle thinkgs like "mget *.jpg" instead of only "mget *"

Also check out the Net::FTP module review -- the comments discuss the lack mput/mget and alternatives.

Replies are listed 'Best First'.
Re^2: Net::FTP Mget
by mikeock (Hermit) on Oct 11, 2005 at 15:33 UTC
    David. It appears that I forgot to assign that array value. Also, won't $file2 =~ s/^(.+ )(.+?)$/$2/; break for files with spaces in them? It is there to take out the rest of the filename from the dir listing. It gets the whole filename to the space and then just the filename. You do bring up a good point as I have yet to test it with a filename that has spaces in it.
      Fixed space issue with  $file2 =~ s/^(.+ )(.+? ?.+?)$/$2/;
        That's no different than the original s/^(.+ )(.+?)$/$2/ because of the greediness of the first .+ ...
        perl -le '$_="-r--r--r-- date user group blah and stuff.txt"; s/^(.+ +)(.+? ?.+?)$/$2/; print '
        And the attempt to fix it with .+? ?.+? to check for an optional space is insufficient .. it will failt for filenames with two or more spaces, and also for filenames with no spaces, it will think the previous column (date or whatever) is part of the filename ...

        It might be more robust to use Net::FTP's ls() method instead so you don't have to parse out the other items from the long format that dir() provides. As for excluding directories and links, you could just let them through and have the get fail on those, or maybe combine both ls() and dir() to figure out which are links/directories.