Re: How to tally money datatype?

2002-11-24 Thread John W. Krahn
Chris wrote: > > So to put it all together. I am able to re-format a money datatype in > dollars to integer pennies with truncate/pad like so > > $amount = -11555; > $amount = -11555.; > $amount = -11555.9; > $amount =~ s/(?<=\.\d\d)\d+$//; > $amount .= ".00" unless $amount =~ tr/.//; > $amo

Re: How to tally money datatype?

2002-11-23 Thread chris
On Sat, 23 Nov 2002 19:42:21 -0800, [EMAIL PROTECTED] (John W. Krahn) wrote: > >If rounding does what you want then that should be fine. However, if >you want to truncate this is one way to do it: > >my $amount = 11555.99; > >$amount =~ s/(?<=\.\d\d)\d+$//; > > > >John So to put it all togeth

Re: How to tally money datatype?

2002-11-23 Thread John W. Krahn
Chris wrote: > > On Sat, 23 Nov 2002 18:44:58 -0800, [EMAIL PROTECTED] (John W. Krahn) > wrote: > > >Chris wrote: > >> > >> OK. I will try it. My amounts look more like this. > >> > >> @dollars = qw/ 12345.67 -12345.67 11555.99 -11555.99 9765.353 > >

Re: How to tally money datatype?

2002-11-23 Thread chris
On Sat, 23 Nov 2002 18:44:58 -0800, [EMAIL PROTECTED] (John W. Krahn) wrote: >Chris wrote: >> >> OK. I will try it. My amounts look more like this. >> >> @dollars = qw/ 12345.67 -12345.67 11555.99 -11555.99 9765.353 > ^^^^ ^^^

Re: How to tally money datatype?

2002-11-23 Thread John W. Krahn
Chris wrote: > > How do I stop the warning message > Possible attempt to separate words with commas at > @dollars = qw/ $12,345.67 $11,555.99 $9,765.35 $432 $876.4 /; my @dollars = ( '$12,345.67', '$11,555.99', '$9,765.35', '$432 $876.4' ); John -- use Perl; program fulfillment -- To unsubs

Re: How to tally money datatype?

2002-11-23 Thread John W. Krahn
Chris wrote: > > OK. I will try it. My amounts look more like this. > > @dollars = qw/ 12345.67 -12345.67 11555.99 -11555.99 9765.353 ^^^^ ^^^ > -9765.353 432 -432 876.4 -876.4/; ^^^ You are going to have to decide if

Re: How to tally money datatype?

2002-11-23 Thread Paul Johnson
On Sat, Nov 23, 2002 at 06:06:12PM -0500, chris wrote: > How do I stop the warning message > Possible attempt to separate words with commas at > @dollars = qw/ $12,345.67 $11,555.99 $9,765.35 $432 $876.4 /; no warnings "qw"; It is lexically scoped. -- Paul Johnson - [EMAIL PROTECTED] http://ww

Re: How to tally money datatype?

2002-11-23 Thread chris
On Fri, 22 Nov 2002 21:21:42 -0800, [EMAIL PROTECTED] (John W. Krahn) wrote: >Chris wrote: >> >> How do I tally money with perl? > >Assuming that you are tallying dollars like $12,345.67, convert to cents >(an integer) by removing all punctuation and convert back to dollars to >print the final to

Re: How to tally money datatype?

2002-11-23 Thread chris
On Fri, 22 Nov 2002 21:21:42 -0800, [EMAIL PROTECTED] (John W. Krahn) wrote: >Chris wrote: >> >> How do I tally money with perl? > >Assuming that you are tallying dollars like $12,345.67, convert to cents >(an integer) by removing all punctuation and convert back to dollars to >print the final to

Re: How to tally money datatype?

2002-11-22 Thread John W. Krahn
Chris wrote: > > I am retrieving rows with a money datatype from a database. These are > written to a file with 2 decimal places. I also keep a running total. > My problem is the total does not equal to the sum of details. > > I have tried using > $amount = sprintf('%.2f', $amount); > $total += $

How to tally money datatype?

2002-11-22 Thread chris
I am retrieving rows with a money datatype from a database. These are written to a file with 2 decimal places. I also keep a running total. My problem is the total does not equal to the sum of details. I have tried using $amount = sprintf('%.2f', $amount); $total += $amount; # do this after all