package Foo; use strict; sub erf { my ($self) = shift; print $self->name(); } sub new { my ($proto, $args) = @_; my $class = ref($proto) || $proto; my $self = {}; if (ref($args) eq 'HASH') { if (exists $args->{'name'}) { $self->{'_name'} = $args->{'name'}; } else { return undef; } } else { $self->{'_name'} = $args->name(); } bless $self, $class; return $self; } sub name { my ($self) = shift; return $self->{'_name'}; } package Foo::Bar; use strict; @Foo::Bar::ISA = qw/Foo/; sub doit { my ($self) = shift; $self->erf(); } package main; use strict; my %hash = (name => 'Homer'); my $foo = Foo->new(\%hash); my $bar = Foo::Bar->new($foo); $bar->doit();