sk has asked for the wisdom of the Perl Monks concerning the following question:
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to conditionally terminate finddepth?
by graff (Chancellor) on Sep 12, 2005 at 22:15 UTC | |
by runrig (Abbot) on Sep 12, 2005 at 22:32 UTC | |
by fizbin (Chaplain) on Sep 13, 2005 at 03:58 UTC | |
by PodMaster (Abbot) on Sep 13, 2005 at 20:20 UTC | |
by sk (Curate) on Sep 12, 2005 at 22:27 UTC | |
|
Re: How to conditionally terminate finddepth?
by GrandFather (Saint) on Sep 12, 2005 at 22:08 UTC |