ric Wilhelm wrote:
In my Inline::C based CAD::Drawing::IO::DWGI.pm, I've been using the following check under perl 5.6.1 without any problems:

        if(! SvNOK(val))
                croak("not a double");
        dwg->aden->arc.radius = SvNV(val);

Then, after upgrading to 5.8.3, that caused problems with the number 1, so I changed it to this:

        if(! (SvNOK(val) || SvIOK(val)))
                croak("not a number");
        dwg->aden->arc.radius = SvNV(val);

Now, that fails if the number came from a string. So, what now? If I just get rid of the check altogether, the magic works as expected. Is this "the right way" (TM)


Yes but if someone passes it a string that is not a number (eg 'hello world'), what happens then ? Or if a reference gets passed to it.


How about:

if(!looks_like_number(val)) croak("Not a number");
dwg->aden->arc.radius = SvNV(val);

I think that might cover all bases, so to speak.

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