#!/usr/bin/perl use strict; use warnings; package Foo; sub new { my $invocant = shift; my $class = ref($invocant) || $invocant; my $self = { }; bless $self, $class; $self->{baz} = 1; $self->{bah} = 2; return $self; } sub baz { die "baz() not overriden\n"; } sub bah { die "bah() not overriden\n"; } package Bar; our @ISA = qw(Foo); for my $field (qw(baz bah)) { my $slot = __PACKAGE__ . "::$field"; no strict 'refs'; # Need symbolic refs to typeglob *$field = sub { my $self = shift; $self->{$slot} = shift if @_; return $self->{$slot}; }; } package main; my $obj = Bar->new(); print "Baz: ", $obj->baz, "\n"; print "Bah: ", $obj->bah, "\n";