APM: Clarified OOP problem

Wayne Walker wwalker at broadq.com
Sun Sep 14 11:34:18 CDT 2003

I have an issue about dynamically calling Class methods (rather than
object methods) from a derived Class.  Any help would be appreciated.

The most important note here is that these are Class methods, NOT object
methods.  Therefore, there is no object.

There is no object, no $self, the methods are being called by
full name.

Because of the ISA relationship, calling Foo::<any subclass>::get_data
will call Foo::get_data, since get_data is not defined in any of the

That part is working as advertised.  $class IS being properly set to the
Name of the class (not a blessed referent, just the text string name of
the class).  Therefore, I thought that perl would handle:

# $class = 'Foo::Bar'

by executing


What syntax would replace $class::get and do what I want it to.

$miracle = Foo::Bar::get_data();

package Foo;

sub get_data
        my $class = shift; # this will =  Foo::Bar at runtime
        $magic_dust = $class::get_dust();
        $miracle = convert($magic_dust);
        return $miracle;

package Foo::Bar

use base 'Foo';

sub get_dust
        # stuff....
        return convert($beans);

The problem is that I cannot get the syntax right to run
Foo::Bar::get_dust() inside Foo::get_data().

There will also be Foo::Baz::get_dust().

Applications will call the non-existant Foo::Baz::get_data
Foo::Bar::get_data, etc...


Wayne Walker

www.broadq.com :)  Bringing digital video and audio to the living room

More information about the Austin mailing list