That's a problem with Inside-Out Objects
For Data::Dumper, yes, because its OO approach is broken. Not so for Storable. I was speaking generically.
You can't expect to clone an object by copying it's bytes or it's fields.
Ditto for changing its properties by directly accessing its hash, which is why this is a mess.
Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.