in reply to Plugin-type architecture
Well, there are many ways you can go with this, so I will give you some ideas that you can combine to meet your own needs.
It is probably a good idea to design an interface that all of your plugins must implement. That way, when you do discover what plugins are installed, you can instantiate and work with them.
You will probably identify a plugin directory. You can easily get a list of .pm files in the directory:
my @plugins = <plugins/*.pm>;
or even use File::Find to recursivly search.
When you have a file you can work with it as such:
for (@plugins) { require $_; # Basically "use"-ing the file s/\//::/g; # Convert the path name into a package name s/\.pm$//; push @pluginInstances, $_->new; # Create a new instance }
So, using file listing features, require (or do or eval), you can list and load your plugins. How you track your plugins within the app and how your plugins integrate will be entirely up to your needs.
Ted Young
($$<<$$=>$$<=>$$<=$$>>$$) always returns 1. :-)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Plugin-type architecture
by philcrow (Priest) on Jan 10, 2006 at 18:43 UTC |