It's true that globals are messy, but that is the way File::Find works. To avoid unexpected behavior with lexical closures, I declare the globals with use vars qw/. . ./; to place them in the symbol table and satisfy strict.
It sounds as if your uses for this are mainly as configuration flags which will not be changed during a run. That is pretty manageable as global variables go.
Update: ++thospel's solution takes advantage of lexical closures to place a wrapper around the find call. Very elegant!. Added: On second look, I think that solution may still have difficulty with closures taking on unexpected values. Localizing the variables may be preferable. Test before you leap.
After Compline,
Zaxo
In reply to Re: Passing arguments to wanted subroutine in File::Find
by Zaxo
in thread Passing arguments to wanted subroutine in File::Find
by jmw_90266
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |