in reply to Pop quiz: find the bug

I prefer this:
my %total; while ( my $data = $t_sth->fetchrow_arrayref ) { my ( $amt, $id ) = @$data; $total{$id} += $amt / PRECISION; } $tcash += delete $total{$CASH} || 0; $taccount += delete $total{$ACCOUNT} || 0; $tcheck += delete $total{$CHECK} || 0; $tgift += delete $total{$GIFT} || 0; $tvoucher += delete $total{$VOUCHER} || 0; $tcc_man_auth += delete $total{$CC_MAN_AUTH} || 0; $tcredit += $_ foreach values %total;
Slightly longer, but much more straightforward. (Although I did need the || 0 bits to make it quiet under warnings.) And, of course, all of the variables following a naming pattern suggests that you would be better off using a hash...

BTW I hope you learned that using short-circuting conditionals as a control structure is a bad idea.