in reply to Recursion up The Inheritance Chain

Are you calling SUPER?
#!perl use strict; package Foo; sub Baz { my $self = shift; print "In Foo->Baz\n"; } sub Quux { my $self = shift; print "In Foo->Quux\n"; } package Bar; use vars qw/@ISA/; @ISA = qw(Foo); sub new { my $class = shift; return bless {}, $class; } sub Baz { my $self = shift; print "In Bar->Baz\n"; $self->SUPER::Baz; } package main; my $snafu = Bar->new; $snafu->Baz; $snafu->Quux; __END__ In Bar->Baz In Foo->Baz In Foo->Quux

Update:added Foo->Quux

Replies are listed 'Best First'.
Re^2: Recursion up The Inheritance Chain
by rwadkins (Initiate) on Dec 18, 2009 at 17:54 UTC
    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.
      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.