Both your tie class and the overloaded add are not quite correct.
The FETCH routine does not return a scalar of the expected kind. You have it returning a reference to the underlying hash, rather than some scalar data stored in it.
An overridden operator like '+' is written like a constructor. It should take data from its arguments and return a new object of the correct type constructed from the result. What you have written for add is a mutator which behaves more like '.=' than '+'. It is a good idea to make sure overridden operators are as much like the builtins as possible.
I'm not sure there is a way to make a tied variable honor the underlying classes' operator overrides. I wasn't aware of that, but my attempts to make it happen have failed.
After Compline,
Zaxo
In reply to Re^2: Overloading assignment
by Zaxo
in thread Overloading assignment
by v_o_i_d
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |