in reply to Re: my $self is stumped!
in thread my $self is stumped!
This makes it very clear what you're doing (always use person's tellName) and isn't as brittle as your second version (if we add a "student" subclass of child, then a student's $self->SUPER::tellName will call child's tellName instead of person's).sub introduce { my($self)=$_[0]; print "Hello, I'm "; # $self->tellName(); # tellName( $self ); person::tellName($self); }
But, as others have said, it's more likely that you don't really want to do this and, if you think you do, you may be confusing classes and instances, so I'd look at it first as a design issue before writing hacky code to make it work.
|
|---|