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

I have found numerous pages that point to the documentation for File::Find and state that preprocess and follow are essentially not compatible. I have looked at the source code for File::Find and have seen that they are indeed kept separate for some reason. What I have yet to find is one explanation of WHY they are mutually exclusive.

Does such a statement exist?

If not, what do you think the chance is for File::Find to be updated to allow the two to coexist? (It would probably be done by adding another configuration parameter, since it might break existing code to simply turn on preprocess functionality across the board.) It seems that File::Find's current design in this regard has existed for quite some time. (Again: why?)

Any insights are appreciated.

  • Comment on Why is preprocess a no-op when follow is true for File::Find?

Replies are listed 'Best First'.
Re: Why is preprocess a no-op when follow is true for File::Find?
by Anonymous Monk on Dec 03, 2010 at 02:40 UTC
    I have found numerous pages that point to the documentation for File::Find and state that preprocess and follow are essentially not compatible.

    Where?

      Directly from the pod as seen at http://perldoc.perl.org/File/Find.html:

      When follow or follow_fast are in effect, preprocess is a no-op.

Re: Why is preprocess a no-op when follow is true for File::Find?
by Anonymous Monk on Dec 03, 2010 at 03:42 UTC
    That module is frustratingly under-commented. And the identifier and sub names could use some work.

    After a glance around, I don't see any condition that prevents pre-processing from occuring. $pre_process is called on the filenames if it's defined, and nothing relating to the follow option (copied to a $full_check) or the follow_fast option (copied to a $follow) ever change that.

    Have you tried it to see that follow really does preclude pre-process? (I haven't.)

      I have tried to use follow with preprocess. They don't work together.

      I looked through the source code for File::Find. If follow is true, the code calls _find_dir_symlink. If follow is false, the code calls _find_dir. Only _find_dir ever calls the preprocess function.

      Why doesn't _find_dir_symlink call it? There are no comments in the code or documentation to describe why this is so. There is only the statement from the doc stating that the two are not compatible.

      I just noticed from the docs that postprocess is likewise a no-op when follow is turned on. Again, it is only called from _find_dir in the code.