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.
pfind – find-or-grep-like utility with Perl syntax
To lowercase only the files names of which contain “blah”, do
To lowercase only the files which contain “blah” inside, do
pfind . /blah/ ‘$_ = lc’
To do recursive “grep foo bar*” in UTF-8 files, do
pfind . “=~ /blah/” ‘$_ = lc’
pfind -utf8 -alllines . ‘/^bar/’ ‘=~ /foo/’ prt_line
Rules: filters and actions
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.