in reply to Re: Formatting Regex for File::Find::Rule
in thread Formatting Regex for File::Find::Rule

Thanks for the quick reply. Makes sense, though '*.*' does continue and returns files as expected. I'll be careful about '.' going forward. That's a wise point.

Do you have any ideas as to why I can't get qr// to work inside name()?

  • Comment on Re^2: Formatting Regex for File::Find::Rule

Replies are listed 'Best First'.
Re^3: Formatting Regex for File::Find::Rule
by haukex (Archbishop) on Apr 09, 2021 at 15:49 UTC
    '*.*' does continue and returns files as expected

    '*.*' is being expanded to a regular expression by File::Find::Rule (more specifically, by glob_to_regex from Text::Glob): m{(?^:^(?=[^\.])(?:(?!\/).)*\.(?:(?!\/).)*$)}

    Do you have any ideas as to why I can't get qr// to work inside name()?

    ->name( qr/LOG|cache|AVCHD/ ) works for me the same as my array suggestion above - like I said it won't work if you keep the slashes in.

      Perfect! Got it to work. The issue was indeed the period in the qr, as you said. Changed it to '\..+' in the pattern, to bypass the current directory, and all is good. Thanks for putting up with me. I knew it was something stupid on my part.
        Thanks for putting up with me. I knew it was something stupid on my part.

        No worries, glad to help! The File::Find::Rule docs aren't 100% clear on that ->name matches the basename only, but I got my insights from peeking at the code - it's basically just compiling to a File::Find routine, which you can see with the private method print $rule->_compile;, and there one can see it's matching against $_, and in File::Find by default that's just the basename of the file, without the directory.