Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
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 musing on the Monastery: (8)
As of 2015-07-28 10:04 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 (254 votes), past polls