fruiture,
Thanks for the reply (as well as everyone else). I tried your code in my script as such:
# Build a Regex
my $rexstr=join'|',map {quotemeta $_} @exts;
my $rex=qr/(?:$rexstr)$/i;
# Directory to Ignore
my $dir = qr/pics/i;
my @list;
# Find the files
find({
wanted =>sub{ print "Found a match: $_\n" if /$rex/;
push @list,$_ if /$rex/} ,
no_chdir => 1,
preprocess => sub { grep not /$dir/ => @_ },
},
$search_root
);
but I'm getting the error: Not enough arguments for grep at test.pl.txt line 30, near "@_ }"
Execution of test.pl.txt aborted due to compilation errors.
I think my syntax is correct. I did end up taking John M. Dlugosz and FamousLongAgo suggestion and use a blank return statement instead and I got it to do what I want.
I'm still curious about this preprocess function though. I could not find any mention to it in the File::Find docs. nor in perlsub Where can I read more on this function?
Also, I went back and read my node and in my text, and next if $string, should have read next if $dir. Hope that didn't confuse anyone.
Thanks,
Dru
Another satisfied monk.
|