APM: Clarified OOP problem

Mike Stok mike at stok.co.uk
Sun Sep 14 11:57:23 CDT 2003


On Sun, 14 Sep 2003, Wayne Walker wrote:

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

I'm not quite sure where the convert ought to live, but does this help 
any?

#!/usr/bin/perl

$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 = $class->convert($magic_dust);
        return $miracle;
}

package Foo::Bar;
                                                                                
use base 'Foo';

sub get_dust
{
        my $class = shift;
        return convert($beans);
}

sub convert {
    print "foo bar convert\n";
}

Mike

-- 
mike at stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       | GPG PGP Key      1024D/059913DA 
mike at exegenix.com                  | Fingerprint      0570 71CD 6790 7C28 3D60
http://www.exegenix.com/           |                  75D2 9EC4 C1C0 0599 13DA




More information about the Austin mailing list