in reply to Squeezing $a+1 to be magical like $a++

There is Yet Another Reason why you really don't want to magicalize the adding operator, and that is the way it handles alphanumeric characters. E.g., 'z9' with ++ becomes 'aa0'. What would you want to do with 'z9' + 'a04'? That promises to get unbelievable messy. And we even haven't touched the subject of fractions... I suggest you leave the magic alone and use sprintf instead.
sub format_add{ my ($x, $y) = @_; my $ret = $x + $y; my $digs = length $x; sprintf("%0${digs}d", $ret ); }
Of course you can overload the '+' with this sub.


The ++ can do some strange things, by the way:
$a=0.5; print ++$a; #prints 1.5 $a='a0.5'; print ++$a; #prints a6 #(so ++ ignores the dot and squashes the 0) $a='2a'; print ++$a; #prints 3 #(because 2a in numeric context returns 2)

Apparently it is a beast to handle with care.

Jeroen
"We are not alone"(FZ)