in reply to Remove bless reference or class/package name from method arguments

When overloading binary operators e.g. '+', perl calls the overloading sub/method with 3 arguments - the 2 operator arguments (as objects) and a flag indicating whether perl has swapped the 2 arguments before calling the sub/method (see overload - as you probably already have :-). Therefore, your use of rmvObjRef() is incorrect in this context.

Consider:

use NumObject; my ($a, $b) = (NumObject->new(), NumObject->new()); my $c = $a + $b; my $d = $a->addObjects($b); my $e = NumObject::addObjects($a, $b);
In the above, the assignments to $c, $d & $e result in slightly different invocations of addObjects(), but will all have the same post-run value - assuming the call to rmvObjRef() is removed/commented out.

A user level that continues to overstate my experience :-))

Replies are listed 'Best First'.
Re^2: Remove bless reference or class/package name from method arguments
by binf-jw (Monk) on May 20, 2009 at 10:47 UTC
    Yeah I know about the swap property (1,0 or undef), I added that comment as I thought someone might tell me you'd want to overload '+' to call addObjects and was covering my back ( Infact that method would cause deep recursion ).
    John,