Allows user-defined rules. Your subroutine will be invoked with $_ set to the current short name, and with parameters of the name, the path you're in, and the full relative filename.

Return a true value if your rule matched.

# get things with long names
$rules->exec( sub { length > 20 } );

grep( @specifiers )

Opens a file and tests it each line at a time.

For each line it evaluates each of the specifiers, stopping at the first successful match. A specifier may be a regular expression or a subroutine. The subroutine will be invoked with the same parameters as an ->exec subroutine.

It is possible to provide a set of negative specifiers by enclosing them in anonymous arrays. Should a negative specifier match the iteration is aborted and the clause is failed. For example:

$rule->grep( qr/^#!.*\bperl/, [ sub { 1 } ] );

Is a passing clause if the first line of a file looks like a perl shebang line.

TWO FOR THE PRICE OF ONE

EXPORTS

TAINT MODE INTERACTION

As of 0.32 File::Find::Rule doesn't capture the current working directory in a taint-unsafe manner. File::Find itself still does operations that the taint system will flag as insecure but you can use the "extras" feature to ask File::Find to internally untaint file paths with a regex like so:

my $rule = File::Find::Rule->extras({ untaint => 1 });

Please consult File::Find's documentation for untaint, untaint_pattern, and untaint_skip for more information.

BUGS

The code makes use of the our keyword and as such requires perl version 5.6.0 or newer.

Currently it isn't possible to remove a clause from a rule object. If this becomes a significant issue it will be addressed.