in reply to How do I make Net::FTP use wildcards
So I modified your code below to do that (it is untested, but the premise should work fine for you)
sub ftp_start { my ($ftp, $meetNo); my ($root, $filename); my (@directories); # the Perl regexp mask to get all files my $mask = "."; ### THESE 3 WORK FINE: $ftp = Net::FTP->new("atd77.acs.org", Debug => 0) or die "Cannot connect to some.host.name: $@"; $ftp->login("USERNAME",'PASSWORD') or die "Cannot login ", $ftp->message; $ftp->cwd("$REMOTE_DIR") or die "Cannot change working directory ", $ftp->message; # Here is new code my @files = $ftp->ls("$REMOTE_DIR"); @files = grep { $_ =~ /$mask/ } @files; for my $file ( @files ) { $ftp->get("$file") or die "get failed ", ftp->message; } $ftp->quit; }
Updated to note that this version works with Perl RegExp as the mask.
|
|---|