I would like to search through all the files in a directory, and see if at least one of them is new (m-time, say). When I find one, i need to stop the depth-search.
Your thoughts will be highly appreciated!
use strict; use warnings; use File::Find; my $base = '/my/working/directory'; finddepth(\&no_old_dir_please, $base); sub no_old_dir_please { return if ((-M $_) <= 30); # how to quit finddepth on this con +dition? }
I know I could set a flag once i hit a new file and then just return in the sub if that flag is true. But the reason i want to stop processing is that there could 100 /1000 more files but the moment I find a new file there is no point in checking other files.
To summarize in the problem in a line: Flag the given directory as "old" if there are no new files (based on some m-time condn).
Thanks!
-SK
Update: I don't want to quit the program as I could be checking a bunch of directories like this in a loop.
In reply to How to conditionally terminate finddepth? by sk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |