in reply to Re: Re: Instance field access from private methods
in thread Instance field access from private methods
Let me know if I'm wrong, but this sure looks like it's inheriting something w/o $self being passed to me.
But it *is* passed, actually $bob is passed as the first element of @_ which is seen in the output
Goodbye C2=HASH(0x177f054) World
So you would normally shift off the first element to a lexical variable often called $self to use the subroutine as a method in OO-style
sub printGoodBye { my $self = shift; print "Goodbye "; $self->printWorld(); } sub printWorld{ my $self = shift; print "World\n "; }
So inheritance is really in play here.
I am also a newbie when it comes to perl-OO, so I watch this thread with keen interest.(++)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Re: Instance field access from private methods
by markcsmith (Novice) on Oct 23, 2002 at 20:08 UTC | |
by perrin (Chancellor) on Oct 23, 2002 at 21:31 UTC | |
by guha (Priest) on Oct 23, 2002 at 21:39 UTC |