EXAMPLE

Why would you want to do this? Say you have something that wants to pass an
object to a number of different plugins in turn. For example you may
want to extract meta-data from every email you get sent and do something
with it. Plugins make sense here because then you can keep adding new
meta data parsers and all the logic and docs for each one will be
self contained and new handlers are easy to add without changing the
core code. For that, you might do something like ...

This can be trivally extended so that plugins could save the email
somewhere and then no other plugin should try and do that.
Simply have it so that the "examine" method returns 1 if
it has saved the email somewhere. You might also wnat to be paranoid
and check to see if the plugin has an "examine" method.

INNER PACKAGES

If you have, for example, a file lib/Something/Plugin/Foo.pm that
contains package definitions for both "Something::Plugin::Foo" and
"Something::Plugin::Bar" then as long as you either have either
the require or instantiate option set then we'll also find
"Something::Plugin::Bar". Nifty!

OPTIONS

You can pass a hash of options when importing this module.

The options can be ...

sub_name

The name of the subroutine to create in your namespace.

By default this is 'plugins'

search_path

An array ref of namespaces to look in.

search_dirs

An array ref of directorys to look in before @INC.

instantiate

Call this method on the class. In general this will probably be 'new'
but it can be whatever you want. Whatever arguments are passed to 'plugins'
will be passed to the method.

The default is 'undef' i.e just return the class name.

require

Just require the class, don't instantiate (overrides 'instantiate');

inner

If set to 0 will not search inner packages.
If set to 1 will override "require".

only

Takes a string, array ref or regex describing the names of the only plugins to
return. Whilst this may seem perverse ... well, it is. But it also
makes sense. Trust me.

except

Similar to "only" it takes a description of plugins to exclude
from returning. This is slightly less perverse.

package

This is for use by extension modules which build on "Module::Pluggable":
passing a "package" option allows you to place the plugin method in a
different package other than your own.

file_regex

By default "Module::Pluggable" only looks for .pm files.

By supplying a new "file_regex" then you can change this behaviour e.g

file_regex => qr/\.plugin$/

METHODs

search_path

The method "search_path" is exported into you namespace as well.
You can call that at any time to change or replace the
search_path.