Hi,

Why does 'looks_like_number()' report that an SvRV looks like a number ?
Are there occasions where programmers want to be able to perform arithmetic operations on the address value of a perl reference ?


It seems odd to me that the following utters no warning, silently multiplying the address value by 2.

use warnings;
$x = 'hello world';
$y = \$x;
print $y, "\n";
$y *= 2;
print $y, "\n";
__END__

I mean: multiplying $y by 2 makes as much sense as multiplying $x by 2 ... yet only the latter produces a warning.

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 */


No big deal .... I'm just wondering if there are good reasons for having 'looks_like_number()' work that way ..... and (assuming there are good reasons) wondering what they are.

Cheers,
Rob

--
Any emails containing attachments will be deleted from my ISP's mail server before I even get to see them. If you wish to email me an attachment, please provide advance warning so that I can make the necessary arrangements.




Reply via email to