Algorithm::IncludeExclude lets you define a tree of include / exclude rules and then allows you to determine the best rule for a given path. WWW: http://search.cpan.org/dist/Algorithm-IncludeExclude/