in reply to Re: Parent cannot call Child method
in thread Parent cannot call Child method

Thank you.

I tried it that way and got this error:

Can't locate object method "new" via package "MyParent::MyChild" (perh +aps you forgot to load "MyParent::MyChild"?) at

This is how I changed the original call:

use MyParent::MyChild; my $obj = MyParent::MyChild->new(); $obj->parent_nifty_method1;

I tried use MyParent in addition to use MyParent::MyChild, neither worked.

Replies are listed 'Best First'.
Re^3: Parent cannot call Child method
by jellisii2 (Hermit) on Mar 17, 2016 at 13:28 UTC
    Did you, as Eily suggested, use parent qw(Parent); in MyParent::MyChild?
      Yes, this is the start of MyChild after reading Eily's post:
      package MyParent::MyChild; use strict; no strict "refs"; use Carp qw(croak); use parent qw(MyParent); my $VERSION = .01; sub new { my ($class) = @_; my $self = {}; bless $self, $class; return $self; }

        I can call MyParent::MyChild->new() just fine with this MyChild code, but I had to modify MyParent (remove the return line in new) so that It would compile. But since MyParent::MyChild defines its own new method, MyParent.pm should not even be needed for that call to succeed ...