use Symbol 'gensym'; # Create a new object in a new class. gensym() isn't strictly required. Anything that makes namespaces would be sufficient. This is just convenient. my $obj = gensym; my $class = *$obj{NAME}; bless $obj, $class; # Install a method *{"$class\::a_method"} = sub { whatever };