in reply to plugins and inheritance

As Corion already suggested, I'd use require to pull in the modules you need.

I would ensure plugins are installed in a special directory, outside Perl's normal @INC, which only contains plugins.

I'd write an AUTOLOAD subroutine in the main code using File::Find to determine the names of all plugin modules (and cache this information to speed up subsequent calls to AUTOLOAD), then require in any module whose name matches the plugin you are looking for.

I'm not sure how you'd deal with multiple plugins that offer similar functionality, such as Module::Offering::this and Another::Provider_of::this, but then I'm not totally clear on exactly what you want to achieve.

I hope this is useful. Of course, TIMTOWTDI!

Replies are listed 'Best First'.
Re: Re: plugins and inheritance
by dash2 (Hermit) on Feb 27, 2001 at 20:22 UTC
    That sounds rather clever to me. So, my AUTOLOAD routine would check for plugins with the required subroutine, but failing that would just use the default. In effect, all my subroutines would be routed via AUTOLOAD first...

    Yeah, that is a really nice solution - my only worry wd be, will all the AUTOLOAD calls consume a lot of time and CPU? I guess there's no easy way round that anyway. If I want easy plugins, I have to get runtime subroutine lookups.

    thanks a lot
    dave

      If your subroutines don't do much work, or you're calling them recursively, then the overhead of an AUTOLOAD technique might be prohibitive. Otherwise, I wouldn't worry about it.

      I recall Damian Conway's Object Oriented Perl describing a technique to declare subroutines when AUTOLOAD is called, so after the first call there is no AUTOLOAD overhead. If you're concerned enough, you might want to investigate that.

      Update: The syntax for this is:

      *{$name_of_subroutine_to_create} = \&Name::of::existing::subroutine