Not that I approve of this, but you would need to overload binary + to recognise when it is called in void context. Otherwise my $y = $x + 1; would modify $x with chaos resulting. I don't think there is a way to do that in the manner of wantarray.
When you write a method that overrides a binary operation (like add), the method gets passed three arguments - the two operands and a third argument which tells you if the operands have been swapped (for code like 1 + $obj). If this third argument is undef then the original statement is in void context.
Blessed Be
The Pixel
In reply to Re: Re: Squeezing $a+1 to be magical like $a++
by pixel
in thread Squeezing $a+1 to be magical like $a++
by coolmichael
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |