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.993333 -11555.993333 9765.353 > > ^^^^^^ ^^^^^^ ^^^ > >> -9765.353 432 -432 876.4 -876.4/; > > ^^^ > >You are going to have to decide if you want to truncate or round these > >to cents or if you want to increase the precision of your accumulator to > >fractions of a cent. > > I am able to round with sprintf and number::format. How to truncate?
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.993333; $amount =~ s/(?<=\.\d\d)\d+$//; John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]