satchboost has asked for the wisdom of the Perl Monks concerning the following question:

I've got a base class Foo, which is an Exporter. It has some function foo(), that it exports automatically. (It's some superclass, for example.) I also have Bar which inherits from Foo and Baz which inherits from Bar. So, I have the following:

package Foo; use Exporter; @ISA = qw(Exporter); @EXPORT = qw(foo); sub foo {} package Bar; @ISA = qw(Foo); package Baz; @ISA = qw(Bar);

Now, I want to have foo() be automatically exported into the namespace for Baz the same way it is for Bar. I can't seem to get PERL to do this. Help?

Replies are listed 'Best First'.
Re: Having Exporter export through @ISA
by merlyn (Sage) on Mar 14, 2001 at 22:22 UTC
    Within Bar and Baz, call Foo->import(qw(foo));
(tye)Re: Having Exporter export through @ISA
by tye (Sage) on Mar 15, 2001 at 03:29 UTC

    I'll just add a friendly warning that mixing inheritance and exporting in a single package is usually a sign of a "confused" interface.

            - tye (but my friends call me "Tye")
Re: Having Exporter export through @ISA
by merlyn (Sage) on Mar 14, 2001 at 22:43 UTC
    There's no way to 'push' from Foo up into Bar and Baz? I thought that was what the @EXPORT array was for...
    No, that's not what it's for. There's not "no way". There's just no "polite" way.
Re: Having Exporter export through @ISA
by satchboost (Scribe) on Mar 14, 2001 at 22:23 UTC
    There's no way to 'push' from Foo up into Bar and Baz? I thought that was what the @EXPORT array was for...