this works not as expected:find({wanted => \&wanted,},'/tmp'); sub wanted { print "$File::Find::name\n"; }
edit: and that is because I have not read the complete docs for "preprocess", but stopped after the first sentence. Oh my. See merlyns answer for a solution. if preprocess looks like this:find({wanted => \&wanted, preprocess => \&preprocess, postprocess => \&postprocess},'/tmp'); # wanted see above sub preprocess { print "pre\n"; } sub postprocess { print "post\n"; }
the code does "the right thing". (there is no directory 1 in /tmp, and there are thousands of files) While the first code example willingly traverses my /tmp directory, the second one gives me a rather weird output:sub preprocess { my @dir = @_; print "pre\n"; return @dir; }
According to the docs, I would expect to have preprocess and postprocess being called befor resp. after processing every directory, but the traversal should be not influenced by this. What am I doing wrong here? Or is it a bug?/tmp pre /tmp/1 post
Bye
PetaMem All Perl: MT, NLP, NLU
In reply to File::Find broken with pre/postprocess by PetaMem
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |