use warnings; use strict; package Animal; sub new { my $class = shift; my $self = { 'name' => shift || 'Ologbo', 'tail' => shift || 'Yes', }; return bless $self, $class; } package Cat; use base 'Animal'; sub nameMe { my $self = shift; return $self->{'name'}; } package main; my $cat = Animal->new; print $cat->{'name'}, $/; # Ologbo my $cat2 = Cat->new('Blackky'); print $cat2->nameMe # Blackky