[tpm] currency deformatter

Indy Singh indy at indigostar.com
Thu Feb 5 08:08:16 PST 2009


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


More information about the toronto-pm mailing list