Synopsis
# MyModule.pm
package MyModule;
use Module::Modular;
load_plugins qw<Foo Bar>;
sub load_another_plugin {
load_plugins 'DifferentOne';
}
# MyModule::Plugin::Foo
package MyModule::Plugin::Foo;
sub __init {
my ($class, $name) = @_;
# $class = MyModule::Plugin::Foo
# $name = Foo
# some code here to be run when loaded
}
sub foo {
print "You have been foo'd!\n";
}
Description
Module::Modular allows you, or others, to create plugins for your modules. They are not loaded by default - only when you want them to be. This means you can even load them further on down in your module if you wish. The idea is to have your plugins handle certain tasks you don't want cluttering the core code of your module. I started writing this before I came across another plugin module called Module::Pluggable. So if you like how that one works better, or even prefer the name (I do), then go check it out. This one is different in the sense you explicitly tell your module what plugins to load, and each plugin may have an initialiser ("__init") that will get run once it has been loaded, which I found pretty neat. This module is modular itself. By importing "with" followed by an array of options you can extend the functionality of Module::Modular. Currently just the one option is available ("Accessors") which provides methods for accessing meta data of your plugins. A plugin can only be loaded if it's within the same namespace and within your path (ie: YourModule::Plugin::*)

Comments
Anyway, I don't see the value of this module besides Class::Load, Module::Pluggable. Could you tell us how your solution is different/better?
I have deliberately mentioned Module::Pluggable in the POD in case people find that suits their needs better.
Please sign up to post a review.