dir structure looks like

... lib/B.pm ... lib/C/C1.pm ...
lib/B.pm

As previously stated, B.pm will already exist on your system. Attempting to write new code with "package B;" will cause you all sorts of problems. You should avoid this name.

lib/C/C1.pm

That's fine. The class name will become "C::C1". My previously posted "lib/C1.pm" should be moved to "lib/C/C1.pm", and the first line should be changed to:

package C::C1;

In my "./acd.pl", you should change

use C1; my $c1 = C1::->new();

to

use C::C1; my $c1 = C::C1::->new();

After making those changes, note the difference in the last line:

$ ./acd.pl A=HASH(0x9897d0) A-bar D=HASH(0x989890) D-bar whos_who() is in package: C $self is in package: C::C1

The hexadecimal values in "X=HASH(0xhhhhhh)" will likely be different: that's not significant; you could get different values on separate runs using the same code.

— Ken


In reply to Re^3: object oriented Perl advice / constructor creation in child class by kcott
in thread object oriented Perl advice / constructor creation in child class by smarthacker67

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.