This might clarify the problem with your question. If your Tinia_CanPwn class isa subclass of your Tinia_CanExtender class, as indicated by your code snippet, then there is no "parent instance". There is only one object (instance) and it is an instance of Tinia_CanPwm, that has inhereted methods from the Tinia_CanExtender class ... not from an instance of that class.

#! perl -slw use strict; { package Test1; ## This is the parent class which inherits from not +hing sub new{ my $class = shift; return bless { __PACKAGE__ => 'test1 attribute value' }, $clas +s; } sub whatAmI{ __PACKAGE__ }; ## No SUPER->whatAmI to call! ## No SUPER->selfRef. sub selfRef{ shift } 1; } { package Test2; our @ISA = 'Test1'; ## A subclass which inherits from Test1. sub new{ my $class = shift; my $self = $class->SUPER::new; $self->{ __PACKAGE__ } = 'test2 attribute value'; return bless $self, $class; } sub whatAmI{ shift->SUPER::whatAmI() . '->' . __PACKAGE__; }; sub superRef{ shift->SUPER::selfRef; } sub selfRef{ shift } 1; } { package Test3; our @ISA = 'Test2'; ## A sub-subclass which inherits from Test2 sub new{ my $class = shift; my $self = $class->SUPER::new; $self->{ __PACKAGE__ } = 'test3 attribute data'; return bless $self, $class; } sub whatAmI{ shift->SUPER::whatAmI() . '->' . __PACKAGE__; }; sub selfRef{ shift } sub superRef{ shift->SUPER::selfRef; } 1; } package main; my $obj = Test3->new; print 'I am a ', $obj->whatAmI, $/; print 'My instance id is ', $obj, $/; print 'My instance id in the class is ', $obj->selfRef, $/ +; print 'My instance id in my parent class is ', $obj->superRef, $ +/; print 'My instance id in my grandparents class is ', $obj->superRef->s +uperRef, $/; __END__ P:\test>332433 I am a Test1->Test2->Test3 My instance id is Test3=HASH(0x18360e0) My instance id in the class is Test3=HASH(0x18360e0) My instance id in my parent class is Test3=HASH(0x18360e0) My instance id in my grandparents class is Test3=HASH(0x18360e0)

What this attempts to show is that whilst there are three classes providing methods to the instance $obj, the instance handle is the same regardless of which class you are executing a method from.


Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"Think for yourself!" - Abigail
Timing (and a little luck) are everything!

In reply to Re: Objects: how to get parent object from child $self reference ? by BrowserUk
in thread Objects: how to get parent object from child $self reference ? by Anonymous Monk

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.