Muppet <[EMAIL PROTECTED]> writes: >On Jul 21, 2004, at 3:16 AM, Sisyphus wrote: > >> Why does 'looks_like_number()' report that an SvRV looks like a number >> ? > >i'm going to make a wild guess and say that it's probably something >like RV's hold the address of something else, which is like a number.
Another possible reason for the behaviour is: this used to be an internals thing (like many things now in the API), and was used to test if numeric compare e.g. $foo == $bar made sense. if ($aref == $bref) # sane and that may have leaked. > >> If I wanted to know if a variable is a valid number, I would like >> references to be rejected - hence I would have to be coding: >> if(looks_like_number(y) && !SvROK(y)) /* it's valid */ > >minor point, but it would be more efficient to short circuit this test >on references, since that's just a a simple flag check, e.g.: > > if(!SvROK(y) && looks_like_number(y)) /* it's valid */ Given the expense of looks_like_number() that seems reasonable.