Allow file globbing in preload.exclude

This commit is contained in:
Colin Kuskie 2009-11-16 11:33:14 -08:00
parent 7c240127e8
commit 1db4a7f916
3 changed files with 34 additions and 4 deletions

View file

@ -66,7 +66,7 @@ These functions are available from this package:
Return an array of all the modules in the given namespace. Will search all
@INC directories. C<options> is a hashref of options with the following keys
exclude => An arrayref of modules to exclude
exclude => An arrayref of modules to exclude. A module name can include an asterisk to glob.
onelevel => If true, only find sub modules (children), no deeper
find( "CGI", { onelevel => 1 } ) would match "CGI::Session" but
not "CGI::Session::File"
@ -110,6 +110,12 @@ sub find {
@modulesHash{ @modules } = ( 1 ) x @modules;
delete @modulesHash{ @{ $options->{exclude} } };
@modules = keys %modulesHash;
my @excludePatterns = map { s/(?<!\.)\*/.*/g; $_; } grep { /\*/ } @modules;
if (@excludePatterns) {
my $pattern = join q{|}, @excludePatterns;
my $exclusions = qr/$pattern/;
@modules = grep { ! m/$exclusions/ } @modules;
}
}
### Return valu