in reply to overload conflict between * and *= (as an example)

Another workaround is:

package Value; use overload fallback => 1;

The explanation can be found by reading the overload documentation. Pay special attention to the section entitled Copy Constructor.

Replies are listed 'Best First'.
Re^2: overload conflict between * and *= (as an example)
by yogibimbi (Initiate) on Feb 27, 2012 at 17:24 UTC
    yeah, this took care of it, thanks. I had read that part of the perldoc before, but I could not imagine how this could be relevant, but looking at the section again, lit the light for me;-)
    And any suggestion as to why the rather inconspicious and innocent $test->{obj} = $N; can screw up the entire short program? I guessed that, if Perl would consider the "=" overloaded, it had to work only on lvalues, but the offending $N here is a rvalue, so, why does this produce a reaction at all?

      The reason is that with numbers you can do this:

      my $a = 1; my $b = $a; $a++; $b++; say $a; # says "2" say $b; # says "2"

      But if $a and $b are overloaded references to numbers, then they refer to the same object, so you've actually incremented the same object twice. $a and $b are both 3.

      Perl forces you to deal with (or at least acknowledge that you've thought about) this problem by in certain circumstances forcing you to provide an overload for "=".