If you really want to use File::Find...

## 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

In reply to Re: Get list of first level subdirectories by radiantmatrix
in thread Get list of first level subdirectories by gwhite

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.