## start in the dir above your client dirs
use File::Find;
my @del_dirs;
find(\&del_dirs, '.');
sub del_dirs {
return unless -d $_;
return unless $File::Find::name =~ m{^\./.+?/.+}; # at least in pro
+ject level
return if $File::Find::name =~ m{^\./.+?/.+?/.+}; # but no lower
### check for age or whatnot here, return if you don't want deletio
+n ###
push @del_dirs, 'rm '.$File::Find::name;
}
However, I doubt this is what you want to do. I would suggest:
my @del_dirs;
opendir primary, '.' or die $!;
foreach my $client (readdir primary) {
opendir client, $client or die $!;
foreach (readdir client) {
## check date, etc. use 'next' if you want to keep
push @del_dirs, 'rm '.$client.'/'.$_;
}
closedir client;
}
closedir primary;
In either case, your delete list ends up in @del_dirs;
The glob-based solutions above would work, too, but readdir tends to be faster than glob.
<-radiant.matrix->
Larry Wall is Yoda: there is no try{} (ok, except in Perl6; way to ruin a joke, Larry! ;P)
The Code that can be seen is not the true Code
"In any sufficiently large group of people, most are idiots" - Kaa's Law
|