Below is a small script and results... Can someone example what I am
doing wrong - the sum should produce zero but does not.

#!/usr/local/bin/perl
use vars qw($this_account_total $this_customer_total $this_run_total);
        while (<main::DATA>) {
        chomp;
        my ($amt_gj, $amt_adj) = split /,/;
        print "$amt_gj,$amt_adj\n";
                foreach $amt (($amt_gj, $amt_adj)) {
                        $this_account_total += $amt;
                        print "Running total $this_account_total\n";
                        }
#                       $this_account_total = 0 if
abs($this_account_total) < .01;
        }
        print $this_account_total, "\n";
__DATA__
22438.90,-22146.6
5935.65,-5927.64
2559.48,-2559.48
1986.59,-1986.59
1087.54,-1087.54
185.82,-292.3
0.00,-185.82
0,-8.01

SUN1-BATCH>./test_zero.pl
22438.90,-22146.6
Running total 22438.9
Running total 292.300000000003
5935.65,-5927.64
Running total 6227.95
Running total 300.310000000002
2559.48,-2559.48
Running total 2859.79
Running total 300.310000000002
1986.59,-1986.59
Running total 2286.9
Running total 300.310000000002
1087.54,-1087.54
Running total 1387.85
Running total 300.310000000002
185.82,-292.3
Running total 486.130000000002
Running total 193.830000000002
0.00,-185.82
Running total 193.830000000002
Running total 8.01000000000244
0,-8.01
Running total 8.01000000000244
Running total 2.43538522681774e-12
2.43538522681774e-12

  
http://dmspulsesurvey.myflorida.com/is
 
 
 

 
 

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to