If you want to filter out subdirectories recursive in File :: Find, you should use the preprocess function (and not the $ File :: Find :: prune variable), as this gives you much more control. The idea is to provide a function that is called once for a directory and a list of files and subdirectories is passed; the return value is a filtered list to go to the desired function and (for subdirectories) for recursion.
As msw and Brian commented, your example will probably be better served by glob, but if you want to use File :: Find, you can do something like the following. Here, the preprocess function calls -f for each file or directory that it specified, returning a list of files. Then the requested function is called only for these files, and File :: Find does not recurs in any of the subdirectories:
use strict; use File::Find;
This can be used to create much more complex file crawlers. For example, I wanted to find all the files in the Java project directory without returning to subdirectories starting with β.β, Such as β.ideaβ and β.svnβ created by IntelliJ and Subversion. You can do this by changing the preprocess function:
source share