in reply to Re^2: File::find preprocess problem
in thread File::find preprocess problem

Thanks for clarifying that, I always used it, and seen it used as pruning type of callback; but it is quite confusing, as seen by the widespread recommendation of the File::Find::Rule and Path::Class::Rule modules mentioned above.

I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku ................... flash japh

Replies are listed 'Best First'.
Re^4: File::find preprocess problem
by Marshall (Canon) on Apr 27, 2012 at 11:51 UTC
    I don't understand why so many folks like these other modules when a simple find() will often do the job!
    I guess the documentation could be improved?

    File::Find is a core module and it runs really fast. My hint about this special underscore variable -> that can make a big difference. It took me awhile to learn that "trick", but I very sure that this is true. That is basically about a 2x performance increase if you are doing 2 file tests.

    The overhead to call a subroutine with no args (which is what find() does), is pretty much nothing compared with a file system operation.

    I'm not sure that running \$preprocess even helps in OP's application. Weirdly enough, it may actually be slower due to the processing before calling \$wanted(). But this depends upon how many files/directories are underneath the /advanced/ path's and whether pruning these descent path's out from the directory descent really helps. Also how significant are the number of simple files that are not log files? Maybe these are huge in number to the .log files, maybe not.

    From my experience, the single thing that will drive the performance, is the number of stat(), file system operations.

      I don't understand why ..... a simple find() will often do the job...File::Find is a core module and it runs really fast

      Just look at the discussion in this node, and you have your answer. :-) It needs a cookbook of runnable examples.


      I'm not really a human, but I play one on earth.
      Old Perl Programmer Haiku ................... flash japh
      I have to say I have not done any preprocessing before calling &File::Find::wanted yet. All the sorting happens in there. And, I certainly do not feel compeled enough to run any benchmark (but I can be convinced if other do).

        Rot I thus: I certainly do not feel compeled ...

        Well, I feel strong enough now to note that correct spelling of the last word above should be "compelled".