Perl question for you:
#!/usr/bin/perl
use File::Find;
#Find files
find(\&wanted, $dir);
sub wanted { #Do something }
#Done going through all files, do below:
other stuff { }
So, I basically want to parse a directory and find certain kinds of files. I can do that successfully with File::Find. However, my next step is, once I’m done searching the files, I want to do my next process.
The problem is , whatever, I put after the sub wanted { #Do something } , gets executed, everytime, the file I want is not found! I know this is only logical for the program to do that. But, could you tell me what I’d need to do to accomplish this:
1] Find files : using > sub wanted { #Do something }
2] While no more files to search : >do something else { }
Thanks!
UPDATED ANSWER: (after OP clarified that he simply wants to run some code after
find()finishes searching):Since
find()is not searching in parallel, it will simply return when all of the search is completed. Therefore you don’t need to do ANYTHING special to achieve your goal:ORIGINAL ANSWER
You can set founding of files flag in wanted subroutine: