[tpm] currency deformatter

Ilia samogon at gmail.com
Thu Feb 5 08:28:04 PST 2009


1..4
ok 1 - fixup $65,345.89
not ok 2 - fixup $65.345,89
#   Failed test 'fixup $65.345,89'
#   at agency_fix_contract_value.t line 18.
#          got: '65.34589'
#     expected: '65345.89'
ok 3 - fixup $65,345.89(txincl.)
ok 4 - fixup $65,345.89*
# Looks like you failed 1 test of 4.


On Thu, Feb 5, 2009 at 11:07 AM, Indy Singh <indy at indigostar.com> wrote:
> The code below will do what you want for your test cases.  I'm not sure that
> two lines of code justifies a whole module.
>
> $x = '$24,969.00(txincl.)';
> ($c) = $x =~ /([0-9\.,]+)/;
> $c =~ s/,//g;
> print "$x -> $c\n";
>
> Indy Singh
> IndigoSTAR Software -- www.indigostar.com
>
>
> ----- Original Message ----- From: "Ilia" <samogon at gmail.com>
> To: <tpm at to.pm.org>
> Sent: Thursday, February 05, 2009 10:29 AM
> Subject: [tpm] currency deformatter
>
>
>> I can't believe there doesn't seem to be a CPAN module to parse a
>> currency into a decimal.
>>
>> The function I'm looking for should return a decimal based on various
>> input like:
>> $65,345.89
>> $65.345,89
>> $24,969.00(txincl.)
>> $24,969.00*
>>
>> any extraneous data like "(txincl.)" should be removed. any spaces
>> should be removed.
>>
>> Any takers?
>>
>> ilia.
>> _______________________________________________
>> toronto-pm mailing list
>> toronto-pm at pm.org
>> http://mail.pm.org/mailman/listinfo/toronto-pm
>
>



-- 
Ilia Lobsanov
Nurey Networks - http://www.nurey.com
New Ideas for a New Economy
Python, Perl, Java, Linux & more
Toronto +1 647 996 9087
Boston +1 781 328 1162


More information about the toronto-pm mailing list