in reply to When does '123' become the number 123.0?
I agree with the other monks. Except in some rare circumstances, Perl will do the right thing with your strings at the point that you treat them as numbers.
There's one rare circumstance I haven't seen mentioned however. I ran across it a while ago and wrote about it in Strings and numbers: losing memory and mind. The short version is that if you read the number as a string and then convert it later, it will take up (a little bit) more memory than if you'd converted it immediately upon reading it. Since the extra memory used is so small, the rare circumstance that this makes a difference is when you have millions of stings being treated as numbers. Failing that, this is nothing to worry about.
|
|---|