I have a module which overloads a few operators

snippet:
use overload
     "+" => \&addoffset,
     "-" => \&subtractoffset,
     q("") => \&printit;

the functions are called OK when I code:

$obj + 7;
print $obj;

...although I get a Perl warning saying addition is useless which I would 
expect. Is this like saying resistance is futile?

Anyway, if I simply change the "+" to "+=" ( and do $obj += 7 ) the print 
function no longer works correctly; it returns the offset embedded in the 
module rather than calling the overloaded function.

Even if I allow Perl to magically make the += happen for me it still does 
the same (wrong) thing.

Am I going mad?

Richard

Reply via email to