APM: Clarified OOP problem

Wayne Walker wwalker at bybent.com
Sun Sep 14 12:08:48 CDT 2003


But I sure feel stupid
On Sun, Sep 14, 2003 at 12:57:23PM -0400, Mike Stok wrote:
> 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?
<  Mike set the calling sytax to $class->get_dust()  >

Yes, I swear that I started with $class->get_dust(); and it didn't work.

I must have had something else wrong and thought it was an issue with
how I was dynamically calling a subroutine from another package.

Here's the test program (Mike's version but trimmed to the essentials in
showing the solution to my stupid problem.


use strict;

my $miracle = Foo::Bar->get_data();
print $miracle, "\n";


package Foo;

sub get_data
        my $class = shift; # this will =  Foo::Bar at runtime

        my $magic_dust = $class->get_dust();
	print $magic_dust, "\n";

        return $magic_dust . "via Foo::get_data()";

package Foo::Bar;

use base 'Foo';

sub get_dust
        return "Got dust from Foo::Bar";


Wayne Walker

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

More information about the Austin mailing list