On Thu, 2 Mar 2017 16:50:32 +0000 (UTC)
mailing lists via beginners <beginners@perl.org> wrote:

> $VAR1 = {
> 'work_hours_to_float_try3' => '5.2',
> 'work_hours_to_float_try2' => '4.1',
> 'work_hours' => '4.1',
> 'work_hours_to_float_try1' => '4.10'
> };
> {"work_hours_to_float_try3":"5.2","work_hours_to_float_try2":"4.1","work_hours":"4.1","work_hours_to_float_try1":"4.10"}
> 
> 
> As you can see, the values are strings (note the double quotes around
> the numeric values) and not floats. So the real question is how to
> output float numbers in this case.

Perl automatically converts from number to string and back.

When I try it, I get the following, which seems to be correct.

$VAR1 = {
  'work_hours' => '4.1',
  'work_hours_to_float_try1' => '4.10',
  'work_hours_to_float_try2' => '4.1',
  'work_hours_to_float_try3' => '5.2'
};
{"work_hours_to_float_try3":5.2,"work_hours_to_float_try1":"4.10","work_hours_to_float_try2":4.1,"work_hours":"4.1"}


-- 
Don't stop where the ink does.

        Shawn H Corey

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to