in reply to Dynamic inheritance

You don't particularly need the eval to set @ISA:

no strict 'refs'; @{ "${package}::ISA" } = $base;

Note also that string-eval is slow (the code needs to be compiled each time), so it's worth avoiding when you can; the Spawn() call can be simply:

$self = eval { $package->Spawn() };
.. or if you aren't using the eval() to protect against dying, even:
$self = $package->Spawn();

Hugo

Replies are listed 'Best First'.
Re^2: Dynamic inheritance
by Prior Nacre V (Hermit) on Aug 06, 2004 at 14:14 UTC

    This is absolutely correct.

    In a more general sense, you can perform any array operation on @ISA at runtime to dynamically alter the OO hierarchy. push(), shift(), splice(), etc. all work.

    Regards,

    PN5

      I think there was something about ->can vs writes to ::ISA.
      So it may not work in this case.

        Could you elaborate on that - I'm not quite with you.

        The can() method is in the UNIVERSAL module and is available to all objects - so nothing special there.

        When you say "... writes to ::ISA ...", are you referring to manipulation of @Some::Package::ISA or something else?

        Regards,

        PN5