Re: Converting string to float

2017-03-02 Thread Gil Magno
On Thu, Mar 02, 2017 at 04:50:32PM +, mailing lists via beginners wrote: > > > just to clarify, the real purpose of the script is output the hash to a json > object, so the json output for the script: So you have to "numify" your number: https://metacpan.org/pod/JSON::PP#PERL-%3E-JSON >

Re: Converting string to float

2017-03-02 Thread Илья Рассадин
See docs https://metacpan.org/pod/JSON::PP#simple-scalars You do print Dumper on hash, it stringifies all hash values, so you see such an obscure result for encode_json. If don't dump $hash before encode json you get what you want - work_hours_to_float_try2 is json valid number {"work_hours

Re: Converting string to float

2017-03-02 Thread Shawn H Corey
On Thu, 2 Mar 2017 16:50:32 + (UTC) mailing lists via beginners 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":

Re: Converting string to float

2017-03-02 Thread mailing lists via beginners
just to clarify, the real purpose of the script is output the hash to a json object, so the json output for the script: #!/usr/bin/perl use strict; use warnings; use Data::Dumper; use JSON::PP; my ($input_string, %job_task); sub sanitize_data{ my $data = shift; $data->{'work_hours'} = (split