#!/usr/bin/perl { package Utils; sub new { my $class = shift; my $self = {}; # Bless into the appropriate class my $obj = bless $self, $class; $obj->init(@_); return $obj; } sub init { # does nothing } 1; } { package Utils::MidLevel; @Utils::MidLevel::ISA = qw(Utils); sub init { my $self = shift; my @args = @_; $self->SUPER::init(@args); # Now do initialization of object } 1; } { package Utils::LowLevel; @Utils::LowLevel::ISA = qw(Utils::MidLevel); sub init { my $self = shift; my @args = @_; $self->SUPER::init(@args); # Now do initialization of this class } sub foo { print "foo\n" } 1; } print "Creating new Utils object\n"; my $util = new Utils; #$util->foo(); # can't find method :( print "\n"; print "Creating new Utils::MidLevel object\n"; my $mid = new Utils::MidLevel; #$mid->foo(); # can't find method :( print "\n"; print "Creating new Utils::LowLevel object\n"; my $low = new Utils::LowLevel; $low->foo(); print "\n"; exit;