tanyeun has asked for the wisdom of the Perl Monks concerning the following question:
I am trying to write a program
that will read a csv file from my bank
and sum up the money I spent during the month
the problem is some amount like "1,200.13", "1,105.02"
should add up to "2305.15", but instead
it's getting "2"!!!
I used an array to store the amounts like this
@ary = {"1,200.13", "1,105.02"}
an alternatives I came up with is like this:
Use Regular Expression to detect the ","
and then separate @ary to two :
@ary_basic = {"200.13", "105.02"}
@ary_1000 = {"1", "1"}
Then sum them up separately
But this solution only limits to amounts
that are less than 1 million.
Any better suggestions?
thx in advance :D
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Regular Expression and digits problem(string, arithmetic)
by davido (Cardinal) on Apr 17, 2011 at 00:50 UTC | |
by tanyeun (Sexton) on Apr 17, 2011 at 06:48 UTC | |
|
Re: Regular Expression and digits problem(string, arithmetic)
by GrandFather (Saint) on Apr 16, 2011 at 23:30 UTC | |
by tanyeun (Sexton) on Apr 17, 2011 at 06:46 UTC | |
|
Re: Regular Expression and digits problem(string, arithmetic)
by Util (Priest) on Apr 16, 2011 at 23:40 UTC | |
by GrandFather (Saint) on Apr 17, 2011 at 00:15 UTC |