Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Re: Ignoring a Directory with File::Find

by dru145 (Friar)
on Nov 12, 2002 at 21:37 UTC ( [id://212423]=note: print w/replies, xml ) Need Help??


in reply to Re: Ignoring a Directory with File::Find
in thread Ignoring a Directory with File::Find

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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://212423]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (3)
As of 2024-04-16 13:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found