Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^4: How to capture the "isn't numeric" warning?

by ikegami (Patriarch)
on Jun 15, 2019 at 15:12 UTC ( [id://11101403]=note: print w/replies, xml ) Need Help??


in reply to Re^3: How to capture the "isn't numeric" warning?
in thread How to capture the "isn't numeric" warning?

whereas the latter returns '' (the empty string) for FALSE.

It does not.

$ perl -MScalar::Util=looks_like_number -we' CORE::say 0+""; ' Argument "" isn't numeric in addition (+) at -e line 2. 0 $ perl -MScalar::Util=looks_like_number -we' CORE::say 0+looks_like_number("abc"); ' 0

It returns the usual empty string, 0, 0.0 triple-var Perl uses for false (sv_no).

Replies are listed 'Best First'.
Re^5: How to capture the "isn't numeric" warning?
by syphilis (Archbishop) on Jun 16, 2019 at 02:24 UTC
    It does not.

    Really ??
    Could you show me a Devel::Peek::Dump output for the scalar returned by S::U::looks_like_number('abc') - one that shows that the empty string is not returned ?
    (Also, the version number of Scalar::Util on which this happens, and the 'perl -V' output.)

    Scalar-Util-1.45 (perl-5.16.0):
    C:\>perl -MScalar::Util -MDevel::Peek -le "Dump(Scalar::Util::looks_li +ke_number('abc'));" SV = PVNV(0x726f74) at 0x723250 REFCNT = 2147483647 FLAGS = (IOK,NOK,POK,READONLY,pIOK,pNOK,pPOK) IV = 0 NV = 0 PV = 0x7229b4 ""\0 CUR = 0 LEN = 12
    Scalar-Util-1.5 (perl5.30.0):
    C:\>perl -MScalar::Util -MDevel::Peek -le "Dump(Scalar::Util::looks_li +ke_number('abc')); SV = PVNV(0x2ea0a8) at 0x2e8150 REFCNT = 2147483647 FLAGS = (IOK,NOK,POK,READONLY,PROTECT,pIOK,pNOK,pPOK) IV = 0 NV = 0 PV = 0x6ff24e83 "" CUR = 0 LEN = 0
    My assertion the "the empty string is returned" could well be deemed incomplete because the IV and NV slots are also filled.
    But the PV slot definitely contains the empty string, and it's the contents of the PV slot that are displayed by print().

    AFAICS, any assertion that looks_like_number does not return the empty string for FALSE is complete bullshit.
    (But I upvoted your post anyway - on the strength of the boldness and abrasiveness of its opening assertion.)

    Cheere,
    Rob

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11101403]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (4)
As of 2024-04-20 01:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found