in reply to Side effects of use-ing base (vs our @ISA)

Howdy!

use base ... does more than simply add stuff to @ISA; it also uses the modules. If you add use Exporter; to your version that modifies @ISA, it should work as you expected.

yours,
Michael

Replies are listed 'Best First'.
Re: Re: Side effects of use-ing base (vs our @ISA)
by ViceRaid (Chaplain) on Sep 10, 2003 at 11:36 UTC

    Thanks, that makes sense to me now. perldoc base:

    'use base qw[Foo Bar]' is roughly equivalent to: BEGIN { require Foo; require Bar; push @ISA, qw(Foo Bar); } ... If any of the base classes are not loaded yet, *base* silently "require"s them.

    It seems like quite a subtle bug to fall into - you can use @ISA directly to declare a subclass of Exporter and think you're getting an import method from the superclass, but actually because you haven't loaded Exporter, silently nothing will happen when you use the subpackage...

    cheers
    ViceRaid

      It seems like quite a subtle bug to fall into

      Yes it does. But what it says to me is: "Don't export. Use the OO scheme fully instead. Minimize use of globals and declare and use them in one file only."

      --Bob Niederman, http://bob-n.com

      All code given here is UNTESTED unless otherwise stated.