package Foo; sub makemethod { my $obj = shift; $obj->{'_codemethod'} = shift; # takes a real code reference # in this implementation, # not a string, so renamed } sub callmethod { my $obj = shift; $obj->{'_codemethod'}(@_); } # . . .