$x = \$r;
I am confused why you're taking this step? This means that $x is a reference, and a reference is like a dual-valued variable*: As a string, it's "SCALAR(0xabc)", which I would guess is what looks_like_number is looking at², and in numeric context, it's the memory address, which is why $x += 1 doesn't warn.
* Update: Triple-valued? It's a reference, string, and number ;-) (Or rather: It's a reference, that gets converted to different values depending on context.)
² Update 2: Hmmm, nope, looks like it's checking the flags in this case.