http://www.perlmonks.org?node_id=1067684


in reply to Replacing objects

You're looking for the bless operator/command/function/whatever it's called:

bless $change, 'NewObj';

The ability to change an object's class at runtime is pretty powerful and can be used for mock objets, for example. However, you should only do this if you are sure that the internal storage is compatible.