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

Greetings Fellow Monks: The goal here is to recursively download files from a directory tree. I have found that Net::FTP::Recursive works quite well for the task. I have listed the cleared code below. I enabled debugging so that I can actually see what is going on, otherwise it just sits their and works but says nothing.
#!/usr/bin/perl -w use strict; use Net::FTP::Recursive; my $ftp = Net::FTP::Recursive->new("ftp.domain.name", Debug => 1); $ftp->login("anonymous",'scientist@site'); $ftp->cwd('/pub/files/'); $ftp->rget(); $ftp->quit;
The next step is to be able to exclude certain files that meet a regex pattern from being downloaded. According to the documentation this can be accomplished by including the parameter OmitAll into the rget() method. The documentation states that I give OmitAll a regex object. So let say we want to filter out files that contain a string "S1499" I implemented the following changes to the code(below) to no avail, can anyone point out perhaps what I am missing?
NEW CODE:
use strict; use Net::FTP::Recursive; my $ignore=qr/S1499/; my $ftp = Net::FTP::Recursive->new("ftp.domain.name", Debug => 1); $ftp->login("anonymous",'scientist@site'); $ftp->cwd('/pub/files/'); $ftp->rget([OmitAll => "$ignore"]); $ftp->quit;
Any help and or insight is greatly appreciated!

Replies are listed 'Best First'.
Re: Need Help With Net::FTP::Recursive
by eric256 (Parson) on May 06, 2004 at 17:54 UTC

    I beleive your trouble is that your are qouteing "$ignore" for no reason and you included , thats there in the documentation to indicate its optional ( I beleive). Try just $ftp->rget(OmitAll => $ignore); or even $ftp->rget(OmitAll => qr/S1499/);


    ___________
    Eric Hodges
Re: Need Help With Net::FTP::Recursive
by sacked (Hermit) on May 07, 2004 at 00:16 UTC
    As shown in eric256's reply (Re: Need Help With Net::FTP::Recursive), the rget method takes a list, not a reference to a list:
    $ftp->rget( OmitAll => $ignore );
    In the pod for Net::FTP::Recursive, the author uses square brackets to denote optional parameters:
    rget ( [ParseSub =>\&yoursub] [,FlattenTree => 1] [,RemoveRemoteFiles +=> 1] )
    The example from the pod above does not mean the method takes a reference to a list. It takes a list of key/value pairs, all of which are optional.

    --sacked
Re: Need Help With Net::FTP::Recursive
by Anonymous Monk on May 06, 2004 at 18:10 UTC
    yes..... you would think that this would do it.... however it doesn't..... could there be a bug? any additional thoughts?

      I assume you were replying to me, in which case could you show the new code you tried?


      ___________
      Eric Hodges