in reply to Extending parent object method?

Here's the problem:

      my $class = ref($self) || $self;

Within reset(), you're trying to get the class of the object. That'll be a string. The parent's reset() method wants an object invocant.

The good news is that you never have to write that ref($self) || $self. Delete it (even from your constructor) and this error should go away.

Your new() could be:

sub new { my $class = shift; my $self = $class->SUPER::new(@_); # do other stuff here for the child object... return $self; }

There's no need to rebless it, provided the parent constructor uses two-argument bless.


Improve your skills with Modern Perl: the free book.

Replies are listed 'Best First'.
Re^2: Extending parent object method?
by Syndaryl (Initiate) on Mar 12, 2012 at 13:51 UTC

    Bingo.

    Now I'm slightly baffled that "STRING::CLASS"->SUPER::new(@_); even works, but I think I'm not going to sweat that until I recover from Daylight Savings Jetlag."

      I'm slightly baffled that "STRING::CLASS"->SUPER::new(@_); even works.

      Perl's method dispatcher handles the SUPER:: case in a special fashion. It looks weird, but it works.