in reply to Prune File Find search

You could just use the preprocess argument
find({ preprocess => sub { return grep { not(-d and /dir(?:One|Two|Three)/) } @_ }, wanted => \&processSub, }, $startDir);
Or (you knew it was coming folks) with File::Find::Rule
use File::Find::Rule; my $iter = rule( not => rule( directory => name => qr/dir(?:One|Two|Three)/, prune => ), start => '/your/path/here' ); while(my $thing = $iter->match) { ... }
See. File::Find::Rule docs for more info.
HTH

_________
broquaint

Replies are listed 'Best First'.
Re: Re: Prune File Find search
by Anonymous Monk on Jul 28, 2003 at 15:38 UTC
    thanks, i tried this and it still prints 'dirOne','dirTwo', and 'dirThree'. Please advise. Thanks
    use strict; use File::Find; my $startDir = '/mypathhere'; unless (-d $startDir) { die "Directory '$startDir' is not a Directory.\n"; } find({ preprocess => sub { return grep { not(-d and /dir(?:dirOne|dirTwo|dirThree)/) } @_ }, wanted => \&processSub, }, $startDir); sub processSub { if(-d $_) { print "$File::Find::name\n"; } }
      Yes ... that's because you changed the regexp in the grep, it should be
      preprocess => sub { ## added ^ and $ return grep { not(-d and /^dir(?:One|Two|Three)$/) } @_ },
      See. your local perlre for more info on alternations (the | metacharacter), and anchors (as seen by the ^ and $ in the regexp).
      HTH

      _________
      broquaint

        Mr broquaint,

        THANKS!!! It works great and I appreciate all your answers and time. I learned alot off this thread thanks to your help.