File::Find is a very nifty perl module on CPAN for finding files by whatever criteria and operating on them. Its docs say:
See also the script pfind on CPAN for a nice application of this module.
which becomes a little cryptic when you see there is no pfind on CPAN. But here’s pfind and it’s a pretty nifty tool to have alongside ack for replacing complicated find/grep pipelines.
NAME
pfind – find-or-grep-like utility with Perl syntax
SYNOPSIS
To lowercase only the files names of which contain “blah”, do
pfind . /blah/ ‘$_ = lc’
pfind . “=~ /blah/” ‘$_ = lc’
pfind -utf8 -alllines . ‘/^bar/’ ‘=~ /foo/’ prt_line
DESCRIPTION
usage:
pfind debug] [-nosubdir] [-bin] [-bak=suffix] [-alllines] [-utf8] [-vars] [-nochdir] [-opts=OPTIONS] [- startdir rule1 rule2 …
Rules are perl statements to execute. Statements starting with “-”, “/”, “$dir =~”, “$dir !~”, “$name =~”, “$name !~”, or “!” are considered filters, a file will be discarded unless the statement returns true.
Statements starting with “=~” (possibly negated by prepending “!”) are filters applied to the contents of the file. The rest is executed as is.
Rules are executed in the directory of the file.