package Factory; sub makeThing { my ($class, @args) = @_; my $thingClass = $class->thingClass; my $thing = $thingClass->new(@args); $class->magicStuff($thing); return $thing; } sub thingClass { 'Thing' } sub magicStuff { my ($class, $thing) = @_; # pretend there's generic magic stuff here }