Hello,

I've been going through perldoc perlboot and I have a question about using the SUPER class. Here's the code in the documentation:

#!/usr/bin/perl

use strict;
use warnings;

{
   package Animal;
   sub speak {
      my $class = shift;
      print "a $class goes ", $class->sound, "!\n";
   }
}

{
   package Mouse;
   @Mouse::ISA = qw (Animal);
   sub sound { "squeak" };
   sub speak {
      my $class = shift;
      $class->SUPER::speak;
      print "but you can barely hear it!\n";
   }
}

Mouse->speak; #outputs a Mouse goes squeak!
              #        but you can barely hear it!

It reads: "So, SUPER::speak means look in the current package's @ISA for speak, invoking the first one found. Note that it does not look in the @ISA of $class."

We are calling the method speak using the Mouse class, so $class = Mouse. So when the documentation says SUPER::speak looks in the current package's @ISA for speak, isn't the current package Mouse (which is also $class)? I just don't understand what the note means when it says it does not look in the @ISA of $class. Could someone explain that for me?

Thank you,

Dave

--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to