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]

Reply via email to