in reply to Re: File::Find wanted and preprocess together
in thread File::Find wanted and preprocess together

Not sure I understand what you mean.

In the File::Find manpage, the preprocess routine is called before wanted. Are you implying that I could be using preprocess routine within the wanted routine? If so, could you please give an example?
  • Comment on Re^2: File::Find wanted and preprocess together

Replies are listed 'Best First'.
Re^3: File::Find wanted and preprocess together
by andal (Hermit) on Nov 04, 2010 at 09:54 UTC

    You don't use "bydepth" option. Which means that you can cancel processing of any subdirectory by setting $File::Find::prune=1. So, in your "wanted" function check if the file should be excluded from the processing and then set $File::Find::prune for the directories that should be excluded and simply ignore the files that should be excluded. Something like

    sub my_wanted{ if(exists $skip_them{$_}) { $File::Find::Prune = 1 if -d $_; return; } do_process($_); }

      Thanks for your reply, Andal. I added this logic to my script and it works. It's a great substitute for the 'preprocess' option. Now I can use follow => 1 and still process exclusions efficiently.