if (defined $total {$id}) { $total {$id} += $amt; } else { $total {tocredit} += $amt; }