while (my $data = $sth->fetchrow_hashref) { my $total = $data->{subtotal} * $tax_rate; # do stuff }