vatheck has asked for the wisdom of the Perl Monks concerning the following question:

I am using File::Find::Rule to search for a number of files that are immediately dumped into an array. I am having a problem working with a complex search. what I need to match is

/$thisscalar/ && (/fixedstring1/ || /fixedstring2/)

in the filename. I've done simple searches with this module before but my first complex search has me stumped, so I am coming to you for help.
  • Comment on trouble getting complex File::Find::Rule search working

Replies are listed 'Best First'.
Re: trouble getting complex File::Find::Rule search working
by jasonk (Parson) on Apr 22, 2008 at 02:28 UTC
    File::Find::Rule->name( qr/$thisscalar/ )->or( File::Find::Rule->name( qr/fixedstring1/ ), File::Find::Rule->name( qr/fixedstring2/ ), );

    www.jasonkohles.com
    We're not surrounded, we're in a target-rich environment!

      The docs imply that this simpler method would also work:

      File::Find::Rule->name( qr/$thisscalar/, )->name( qr/fixedstring1/, qr/fixedstring2/, );

      I didn't test it since it wasn't installed here and I find it very unlikely that I'll ever have a use for it. :)

      - tye        

      that is matching the files I wanted, thank you.