in reply to Re: Recursion up The Inheritance Chain
in thread Recursion up The Inheritance Chain

I am calling SUPER, but Baz isn't defined in Bar. It's only defined in Foo. Defining it in Baz would be redundant and if there were more objects in the chain between Foo and Bar, then I wouldn't be able to step up each one. which is wny I wanted recursion.
  • Comment on Re^2: Recursion up The Inheritance Chain

Replies are listed 'Best First'.
Re^3: Recursion up The Inheritance Chain
by keszler (Priest) on Dec 18, 2009 at 17:58 UTC
    I misunderstood your question - I thought you had a sub Baz in both and couldn't get to Foo's. I updated my previous reply with Foo->Quux; no SUPER call needed, just $snafu->Quux.
      Thanks for the help, unfortunately quux doesn't recurse. you're not calling Bar->quux which then calls Foo->quux. I'm trying to create a single method that runs once for every package in the inheritance chain.

        Can you show us your code, so we could get an idea of what are you trying to do? The following works for me:

        use strict; use warnings; use 5.010; package Bar; sub baz { say 'buzzzzz...'; Foo->baz; } package Foo; our @ISA = qw(Bar); package main; Foo->baz; __END__ buzzzzz... buzzzzz... buzzzzz... buzzzzz... ...
        If I'm understanding you, you want to define a Foo->Plugh method but not a Bar->Plugh method, create an instance $snafu of a Bar, call $snafu->Plugh, and execute Bar->Plugh then Foo->Plugh. Is that correct?