in reply to Re: Prune File Find search
in thread Prune File Find search

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"; } }

Replies are listed 'Best First'.
Re: Re: Re: Prune File Find search
by broquaint (Abbot) on Jul 28, 2003 at 15:52 UTC
    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.