Here is a short lil mget that i wipped up for Net::FTP since the module is originally lacking this functionality. The below code assumes that $ftp is the variable used to bring up your ftp service.
$ftp->dir or die "cannot list dir contents\n"; foreach my $file2(@lines){ next if($file2 =~ m/^(d|l)/); # Skips all directorie +s or symbolic links $file2 =~ s/^(.+ )(.+?)$/$2/; # Return jsut the file +name from the string $ftp->get($file2); }

Replies are listed 'Best First'.
Re: Net::FTP Mget
by davidrw (Prior) on Oct 11, 2005 at 15:12 UTC
    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.
      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/;
Re: Net::FTP Mget
by Anonymous Monk on Oct 11, 2005 at 15:02 UTC
    Sorry for the double post. Reap the bottom one this one should be commented properly.