in reply to File::find preprocess problem
However, the preprocess returns everything,
That is kinda what you tell it to do. elsif (-d && /advanced/ ) {push (@toreturn, $_);} means "hey, I've found one I want to ignore, but I choose to NOT ignore , aren't I funny?"
so I need to use the preprocess possibility
Not exactly :)
use File::Find::Rule
use File::Find::Rule; my $rule = File::Find::Rule->new; $rule->or( ## first rule, things to ignore, to skip $rule->new ->directory ->name('CVS', qr/advanced/i ) ->prune ->discard, $rule->new ->file ->name('*.log') ); my @files = $rule->in( @startdirs );
or use Path::Class::Rule , it doesn't use File::Find underneath, and actually names the prune/discard option skip, and provides a real iterator , its brilliant
use Path::Class::Rule; my $rule = Path::Class::Rule->new; $rule->skip( $rule->new->dir->name(qr/advanced/i), $rule->new->skip_vcs ); $rule->file->name('*.log'); # iterator interface my $next = $rule->iter( @dirs ); while ( my $file = $next->() ) { ... }
|
|---|