Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Re^2: Confusion over B::PV

by mje (Curate)
on May 19, 2012 at 17:14 UTC ( #971429=note: print w/replies, xml ) Need Help??

in reply to Re: Confusion over B::PV
in thread Confusion over B::PV

Thank you for the explanation. The test is looking to see that the scalar does not look like a string because it wants to behave like a number because it was a number in the database. The test is simply ensuring the scalar was either created with sv_setiv or sql_type_cast_svpv was run on it.

Before sql_type_cast_svpv or DBDs like DBD::ODBC (here) set the scalar with sv_setiv the scalar looks like a string then you have to add 0 to all your numbers retrieved from the database before passing them to modules like JSON::XS or they will be turned into "NNN" instead of NNN. Another example was people doing select a_int, b_int from table then performing a_int & b_int which gives the wrong answer unless you add 0 to them first. See and various discussions on dbi-dev mailing list.

Replies are listed 'Best First'.
Re^3: Confusion over B::PV
by ikegami (Pope) on May 20, 2012 at 03:21 UTC

    The test is looking to see that the scalar does not look like a string

    You want SvPOK(sv) which is defined to be SvFLAGS(sv) & SVf_POK and is available as $sv->POK.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://971429]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2018-05-25 04:10 GMT
Find Nodes?
    Voting Booth?