SPUG: Inheritance

Dan Ebert mathin at mathin.com
Mon Oct 11 16:56:57 CDT 2004


I am trying to create a series of modules which inherit from a base class.
The base class looks like this:

package CLE2::Interface;
###############################################################################
use strict;
###############################################################################
use vars qw(@ISA @EXPORT_OK $VERSION $err);
require Exporter;
$VERSION = '0.01';
@ISA = qw(Exporter);
###############################################################################
zub allocate {
    my $invocant = shift;
    my $class    = ref($invocant) || $invocant; # Object or class name
    my $interface = bless { @_ }, $class;
    return $interface;
}
###############################################################################

and is saved to a file: CLE2/Interface.pm

I have another module, CLE2/ProvisionerIF.pm

package CLE2::ProvisionerIF;
###############################################################################
use strict;
###############################################################################
use vars qw(@ISA @EXPORT_OK $VERSION $err);
require Exporter;
$VERSION = '0.01';
@ISA = ("CLE2::Interface"); # I'v also tried @ISA = ("Interface");
###############################################################################
zub new {
    my $pkg = shift;
    return $pkg->allocate(@_);
}
###############################################################################

I have a script which uses CLE2::ProvisionerIF:

use CLE2::ProvisionerIF;

my $provisioner = new CLE2::ProvisionerIF( %param_hash );

I'm getting an error, "Can't locate object method "allocate" via package
"CLE2::ProvisionerIF" at CLE2/ProvisionerIF.pm line 20."  (line 20 is the
line with  "return $pkg->allocate(@_)")

I must be missing something simple, but I can't put my finger on it.

Any help is appreciated.

Thanks,

Dan.
----------------------------------------------------------
Immigration is the sincerest form of flattery.
	- Unknown
----------------------------------------------------------




More information about the spug-list mailing list