I am writing tests for a module Child which inherits from Parent, and have run into a oddity which I can't grasp.

These modules are part of a larger framework and it is pretty difficult to strip it down to a non-working snippet of code.

However these are the facts before the crime:

my $o = Child->new; print ref($o); #Child print $o->isa('Child'); # 1 print $o->isa('Parent'); # 1 print join(':', @Child::ISA) # Parent my $method = 'testSign'; my $code = $o->can($method); print $code; # CODE(0x20d5b94)

Either of

$o->$method()
or
$o->$code()

emits the following error
Undefined subroutine &ClientChild::testSign called at program.t line nnn.

The testSign method is only defined in the Parent class.

So whats going on, to me it looks like inheritance does not occur even though the prerequsites seem fulfilled.

Hints, ptrs, wild shots in the dark greatly appreciated!

perl -v #AS-635

update: Thanks adrianh & ysth for spotting my transcription error.

Sort of Solved:Added a method Fubar to Parent. And tested with that, and now it worked. So obviously there was something special with the testSign name. A little searching revealed the testSign was referenced in Child like so

my %_init_mems = ( Password => \&testPassword, Sign => \&testSign, Name => \&testNameX2, Titel => \&testStrX, );

I'm not sure but does this act as a declaration for sub testSign in Child namespace ala ysth's and Ovid's suggestions?

But in that case the testSign in Child ought to have been invoked as a method instead ?


In reply to Failing inheritance or what can make a Child disinherited ? by guha

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.