Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^3: Net::FTP::Recursive code not downloading files

by wazat (Beadle)
on Dec 12, 2013 at 22:31 UTC ( #1066930=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Net::FTP::Recursive code not downloading files
in thread Net::FTP::Recursive code not downloading files

I suspect your MatchDirs may be preventing the recursion. If the matching doesn't use the full path then the subdirectory names won't include the parent directory names.

MatchDirs => qr/PowerEdge R810|R610|R720|R620|M620|M1000E)/,

If that is the case, then you need to run your code on these 6 directories separately.


Comment on Re^3: Net::FTP::Recursive code not downloading files
Download Code
Re^4: Net::FTP::Recursive code not downloading files
by bowei_99 (Friar) on Dec 13, 2013 at 03:44 UTC
    Why would I need to run the code for each directory separately? Isn't that the whole point of recursion, so it will drill down into each directory until there are no more levels? The thing is, I don't know where the text files will be within the directory structure, so I have to traverse every directory and subdirectory.

    Also, on point about the regex. I tried changing it to the following:

    MatchDirs => qr/.*PowerEdge (R810|R610|R720|R620|M620|M1000E).*/,
    but I get the same thing.

    -- Burvil

      Net::FTP::Recursive won't descend into to subdirectory unless the name of the subdirectory matches your pattern. For example, if there is a directory

      PowerEdge R810/TextFiles

      Net::FTP::Recursive will descend into "PowerEdge R810" since it matches. However the subdirectory "TextFiles" does not match your pattern, so Net::FTP::Recursive will ignore it. Net::FTP::Recursive dos not consider a child directory to match simply because a parent did.

      What I was suggesting, was that if you happen to know the where the various "PowerEdge" directories are, you could search each of them separately, omitting the MatchDirs option, thus circumventing the limitations of MatchDirs

      Why would I need to run the code for each directory separately? Isn't that the whole point of recursion, so it will drill down into each directory until there are no more levels?
      MatchDirs is not doing what you think - it is not saying "if a directory matches this pattern go in and recurse". What it is saying is "for every directory do not enter unless its name matches this pattern". Changing the pattern will not help as it tests against the directory name not the path.

      Peeking into the Module's relevant code may help:

      elsif ( $file->is_directory() ) { if( ( $options{MatchDirs} and $filename !~ $options{MatchDirs} ) or ( $options{OmitDirs} and $filename =~ $options{OmitDirs} )){ next FILE; }

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1066930]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2014-08-23 08:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (172 votes), past polls