in reply to File::Find: Return array of "wanted" files

use File::Find::Rule qw/ find /;
my @files = find( file => name => qr/regex/, in => \@dirs, );

  • Comment on Re: File::Find: Return array of "wanted" files (File::Find::Rule)

Replies are listed 'Best First'.
Re^2: File::Find: Return array of "wanted" files (File::Find::Rule)
by hdb (Monsignor) on Oct 04, 2013 at 08:06 UTC

    AFAIK, the OP wanted to apply the regex to the contents of the files, not the names, so it should be:

    my @files = File::Find::Rule->grep( qr/regex/ )->in( @dirs );

      AFAIK, the OP wanted to apply the regex to the contents of the files, not the names, so it should be:

      Go figure, I thought it was a typo, oh well :)

      use File::Find::Rule qw/ find /;
      my @files = find( file => grep => qr/regex/, in => \@dirs, );

        Thanks, File::Find::Rules works great.