On Jul 19, Mark Maunder said: >I'm using __PACKAGE__->method() to call a method that exists in a class >higher up the inheritance tree when $self in the current method is a blessed >object from a class lower down the inheritance tree (relative to the class >in which I'm doing the __PACKAGE__->method() call). The reason I'm calling >__PACKAGE__ is because I want $self in the called method to refer to the >caller rather than the object with exists lower down the heirarchy. I'm >probably not making much sense, so I've included a working example below. I think you mean to do something like this: package Generic; sub foo { ... } sub bar { ... } package Specific; @ISA = 'Generic'; sub foo { ... } A Specific object will use Specific::foo(), but Generic::bar(). If you need to get to Generic::foo(), then you'd use sub foo { my $self = shift; if ($needed) { $self->SUPER::foo(@_); } } -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ I am Marillion, the wielder of Ringril, known as Hesinaur, the Winter-Sun. Are you a Monk? http://www.perlmonks.com/ http://forums.perlguru.com/ Perl Programmer at RiskMetrics Group, Inc. http://www.riskmetrics.com/ Acacia Fraternity, Rensselaer Chapter. Brother #734 ** Manning Publications, Co, is publishing my Perl Regex book ** -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Is __PACKAGE__->method() the best way...
Jeff 'japhy/Marillion' Pinyan Thu, 19 Jul 2001 13:50:12 -0700
- Is __PACKAGE__->method() the best way... Mark Maunder
- RE: Is __PACKAGE__->method() the bes... Jeff 'japhy/Marillion' Pinyan
- RE: Is __PACKAGE__->method() the... Mark Maunder
- Re: Is __PACKAGE__->method()... Michael Fowler
- RE: Is __PACKAGE__->meth... Mark Maunder
- Re: Is __PACKAGE__->... Michael Fowler
- RE: Is __PACKAGE__... Mark Maunder
- RE: Is __PACKAGE__->meth... Mark Maunder
- Re: Is __PACKAGE__->... Michael Fowler