For a long time I've wanted to create a library of ready-to-use functions to pass to File::Find::find(). I can never remember which File::Find variable is what, and I never have liked the idea that I had to code the accculumation of the filenames if I did not process them immediately. This sorrt of thing seemed like it could use a shot of code reuse mojo.
So I created File::Find::Closures to hold all of those sorts of callbacks. The functions in File::Find::Closures have names like find_by_regex(), and return two things: the callback which I give directly to find(), and a reporter closure that can access the list of files the callback acccumulated.
I thought Andy was going in this direction with File::Find::Wanted, but I think he had something else in mind. Randal came close to what I wanted with File::Finder, but without the re-use.
Maybe this is just one of those things that everyone ends up writing for himself.
So far, Find::Find::Closures is a developer release, so you won't be able to get it through CPAN.pm. It has no prereqs (other than File::Find which it uses in the tests). I've outlined what other people need to do to write their own functions for the module, and hope that people will send me cool ones that I can include.
File::Find::Wanted (Score:2)
Now, it IS entirely possible that you could have helper functions, like:
--
xoa
API design (Score:1)
The idea is sound, but I'd rather prefer a different interface.
At the very least I'd like to be able to inline the generator call in the
find()call, maybe by passing in a reference to where to store the iterator. Actually, that makes it really simple to handle the common case where one simply wants a list of files just pass an array reference.