Hi everybody!

A. Pagaltzis wrote:
> The other of the two modules serves as some kind of "control
> center" for the application, providing information about
> modules, functions to find and (un)load them etc.
Are you talking about a plugin mechanism? Something like
Module::Pluggable or Module::Pluggable::Ordered?

Thank you for that pointer - I haven't noticed that one when looking for similar modules...

Yes, it goes a bit in the same direction - however,
the focus is different: the class I've created is thought to
be used in scripts and to provide an easy interface to find,
load and unload modules - thus does some more things and the
way it does them is quite different. For example, "plugins"
are never searched in @INC unless a directory of @INC is
explicitly given...

Another feature ist event management - every module may
register events. When an event is triggered, the modules get
noticed ($module->event_hanler($event_name, @parameters) is
called).

The usage of the modules is about as follows (they are not
completely finished yet, so things may change slightly):
  package main;
  use modularizer;
  local $mod = modularizer->instance();
  $mod->loglevel(100);
  $mod -> module_directory
     ('/home/baltasar/--useradm/work/modules/');
  $mod -> module_extension ('.mom');
  $mod -> module_autoload (1);
  $mod -> modules_register_all(1);
  $mod -> modules_list;
  $mod -> event_trigger('user_update', 'baltasar');
      # notify all modules that need to know about
      # the update of user baltasar
  $mod -> module{'hello'} -> hello ('world');
      # let the hello module print out hello, word!
  $mod -> modules_deregister_all();
      # not needed, automatically done by destuctor
  exit 0;

The hello module looks like this:
  package modularizer::module::hello;

  use modularizer;
  use base qw(modularizer::module);

  sub hello {
     my ($self, $who) = @_;
     print "Hello, $who!";
  }

If that helps, I can also post the code that exists at
the moment or put it on-line somewhere...

Greetings,

Baltasar

Reply via email to