my $total = $sth->rows; my $perPage = 20; my $pageCount = int(($total + $perPage - 1) / $perPage);