gensym doesn't actually create namespaces; they spring into existence on demand. I would just have done something like:
my $obj = {}; my $class = "$obj"; bless $obj, $class; *{"${class}::foo"} = sub { "bar" }; print $obj->foo();
In reply to Re: Smallish mock objects
by ysth
in thread Smallish mock objects
by diotalevi
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |