Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Peculiar incident: printing a variable changes its type

by mje (Curate)
on Nov 13, 2013 at 09:23 UTC ( #1062357=note: print w/ replies, xml ) Need Help??


in reply to Peculiar incident: printing a variable changes its type

Use Devel::Peek and Dump $body->{"timeout"} before and after print. Look at the part called pv. I'm afraid this is what a lot of JSON encoders do, they try to guess whether something is a number by looking to see if your scalar has a pv (has been used in string context) or not. printing your scalar causes the pv to be created.

Some modules (e.g., DBD::Oracle and DBD::ODBC) have had code added to them to allow an attribute to be specified to remove the pv when fetching numbers from a database but this is XS code. I'm unsure how you do it in pure perl but there is bound to be a way.


Comment on Re: Peculiar incident: printing a variable changes its type

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (13)
As of 2014-10-20 09:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (75 votes), past polls