NAME

Module::RegexRequire

SYNOPSIS

use Module::RegexRequire qw: require_regex require_glob :;

require_regex q[DBD::.*];
require_regex qw[DBD::.* Foo::Bar_.*];
require_glob qw[DBD::* Foo::Bar_*];

DESCRIPTION

This module provides a way to load in a series of modules without having to know all the names, but just the pattern they fit. This can be useful for allowing drop-in modules for application expansion without requiring configuration or prior knowledge.

The require_regex function takes a list of files and searches @INC trying to find all possible modules. Only the last part of the module name should be the regex expression (Foo::Bar_.* is allowed, but F.*::Bar is not). Each file found and successfully loaded is added to %INC. Any file already in %INC is not loaded. No import functions are called.

The function will return a list of files found but not loaded or, in a scalar context, the number of such files. This is the opposite of the sense of require, with true meaning at least one file failed to load.

Note that unlike the Perl require keyword, quoting or leaving an argument as a bareword does not affect how the function behaves.

The require_glob function behaves the same as the require_regex function except it uses the glob operator (<>) instead of regular expressions.

SEE ALSO

perldoc -f require.

AUTHOR

James G. Smith <jsmith@cpan.org>

COPYRIGHT

Copyright (C) 2001 Texas A&M University. All Rights Reserved.

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.