my $self = shift; my $factory_class=ref $self; *Foo::bar = sub { return $factory_class->instance; };