Output:
So - you are doing it right !going in in new for cChild and just calling sub_passed_to_child yes in passed_sub $oParent_ref is cParent=HASH(0xf18038) $oParent_ref->{test_att} is 3
If you wanted to pass the CHILD, instead of the parent at:
Then passed_sub would look like:##OLD $self->{sub_passed_to_child}( $self->{parent_obj_ref} ); $self->{sub_passed_to_child}->( $self ); ##New, explicitly d +e-ref the sub
Of course, it would be "better", to use a "getter", so typos would be checked at compile time. </c>sub passed_sub { print "yes in passed_sub\n"; my ($child) = @_; # I don't like using shift here.. print $child->{parent_obj_ref}{test_att}; # 3
"I can cast out either one of your demons, but not both of them." -- the XORcist
In reply to Re: using passed parent object reference to get at attributes
by NetWallah
in thread using passed parent object reference to get at attributes
by previous
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |