Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • Thanks for doin' this, Richard. It's awfully handy to be able to have:
    my $rules = File::Find::Rule->new->file->name( '*.html' );
    $rules->or( $rules->new->directory->name('CVS')->prune->discard, $rules->new );
    my @html = $rules->in( './' );
    to find all the HTML files in my project.


    • Thanks, though I don't think that does quite what you mean.

      What you've constructed is:

      file && name( '*.html' ) && ( ( directory && name( 'CVS' ) && prune && discard ) || anything )

      So it won't be pruning any CVS directories, as file && directory won't fire. The matching path is file && name( '*.html' ) && anything. This does give me an idea though, 0.02 will probably let you query which rules fired for a particular file, if there's a way to do it without impacting on performance too much.

      What I imagine you want is:

      my $rules = File::Find::Rule->new;
      $rule->or( $rule->new->directory->name('CVS')->prune->discard,
                 $rule->new->file->name('*.html') );

      Or, since CVS directories don't typically have anything that's called *.html in them

      $rules = rule( name => '*.html' );

      would probably just do.