Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

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 http://search.cpan.org/~timb/DBI-1.620/DBI.pm#sql_type_cast and various discussions on dbi-dev mailing list.


Comment on Re^2: Confusion over B::PV
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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2015-07-05 10:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (61 votes), past polls