in reply to Intercept Call to another package

Ummm... what's wrong with having Foo inherit from Bar through @ISA? This would mean that the users of Foo would have to understand how to use OO, but that's not that difficult, and it's even a little more intuitive, in many cases.

------
We are the carpenters and bricklayers of the Information Age.

Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.

Replies are listed 'Best First'.
Re: Re: Intercept Call to another package
by Foo::Bar (Acolyte) on Nov 29, 2001 at 00:36 UTC
    So...Foo could override the method in Bar and then call Foo::SUPER->method ? That would work but what if I want to do the same with modules in the future I know nothing about, sort of like a plugin? Maybe there is a better way or my thinking is all wrong. I dont' want to always be updating pacakge Foo. I want Foo to dynamically load Bar, Baz..others (from a config file), basically override the methods for the intercept and then call the method. Also, if I use plain old ISA I could have conflictig method names: Bar->method1, Bax->method1.

    Maybe I'm way of base here...seems like I should be able to do it though.
      Yes, Foo could override the method, then call $self->SUPER::method. (Slight difference, same idea.)

      Now, if you're talking about doing some sort of plugin idea ... that's getting really complicated, involving on-the-fly modifications to @ISA, etc. Essentially, what it sounds that you really want to do is create a dispatch table that would have, instead of a coderef, a list of coderefs (or function names) that would be called in that order.

      There has to be a better way to do what you want to do.

      Period.

      Maybe if you started describing what it is you want to design for, we can help.

      ------
      We are the carpenters and bricklayers of the Information Age.

      Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.

        Yes, Foo could override the method, then call $self->SUPER::method. (Slight difference, same idea.)

        Of course but important difference ;-)...I used Foo so as not to confuse the issue.

        I mucked with dispatch tables and it didn't seem right...oh well back to the drawing board. Thanks.