|Problems? Is your data what you think it is?|
Net::FTP::Recursive code not downloading filesby bowei_99 (Friar)
|on Dec 12, 2013 at 19:25 UTC||Need Help??|
bowei_99 has asked for the
wisdom of the Perl Monks concerning the following question:
I have the following script, which is supposed to recurse through Dell's ftp site and download text files. It gets in, but doesn't download anything. Any thoughts on why?
Below is the code and my analysis/questions.
With nothing in GetFiles (only a return statement), I get this when I run it:
When I add the code to get files, I get the same, except for:
While I could put in code to search for and only download text files, I would have thought that would be already be built into the Recursive module. I get the feeling even modifying the GetFiles subroutine may be overkill, as the cpan page seems to imply (to me, at least) it's not needed. From that page:
If you'd like to provide your own function for parsing the data retrieved from this command (in case the ftp server does not understand the "dir" command), all you need do is provide a function to one of the Recursive method calls.
However, I'm not parsing the data, and I'd think I shouldn't need to, if the correct filter parameter is set. I'm referring to the FlattenTree => 1. From the cpan page:
The FlattenTree optional argument will retrieve all of the files from the remote directory structure and place them in the current local directory. This option will resolve filename conflicts by retrieving files with the same name and renaming them in a "$filename.$i" fashion, where $i is the number of times it has retrieved a file with that name. ... MatchFiles - Only transfer plainish (not a directory or a symlink) files that match this pattern. ... MatchDirs - Only recurse into directories that match this pattern.
I thought it was something with my regexes, so I commented those out, but still the same thing.
What am I missing here? Why isn't the script downloading the text files? UPDATE: Thanks all for your help. Splitting the code out in separate calls for each directory and removing the MatchDirs specification works.