$class::SUPER as well as $instance::SUPER?

M

Matthew Braid

Hi all,

Just a quick question - I just found out that this:

package Bar;

sub woo { print "WOO!\n" }

package Foo;
use base qw/Bar/;

sub woo {
my $class = shift;
$class::SUPER->woo(); # EEK!
print "WOO2!\n";
}

package main;
Foo->woo();
1;
__END__

does not work - the line marked with # EEK! causes perl to die with the message
'Can't call method "woo" on an undefined value at ....'.

I take it that you can't find a _class_'s super class via the ::SUPER construct
(it obviously works for an instance of the class).

Is there something else I can do to accomplish this?

MB
 
S

Sherm Pendley

Matthew said:
Just a quick question - I just found out that this: ....
$class::SUPER->woo(); # EEK! ....
does not work

It works if you write it correctly. ;-)

$class->SUPER::woo();

sherm--
 
M

Matthew Braid

Sherm said:
It works if you write it correctly. ;-)

$class->SUPER::woo();

sherm--

D'oh! That's what I get for writing code on a friday afternoon. Sheesh.

Thanks :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,234
Latest member
SkyeWeems

Latest Threads

Top