Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Peculiar incident: printing a variable changes its type

by mje (Deacon)
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 contemplating the Monastery: (6)
As of 2014-09-17 21:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (99 votes), past polls