my $limited = $dbi->prepare('select Zipcode, Zipname from zips where Zipname like ? order by 1 limit ?,?'); my ( $pagelines, $page) = ( 30, 0); while ($limited->execute( 'A%A', $page++ * $pagelines, $pagelines) && $limited->rows) { my @rec = $limited->fetchrow_array; printf "%2d records starting with: %05d %s$/", $limited->rows, $rec[0], $rec[1]; } =pod Output is: 30 records starting with: 04330 AUGUSTA 30 records starting with: 22301 ALEXANDRIA 30 records starting with: 30316 ATLANTA 30 records starting with: 33920 ALVA 30 records starting with: 47001 AURORA 30 records starting with: 54720 ALTOONA 30 records starting with: 61414 ALTONA 30 records starting with: 67010 AUGUSTA 30 records starting with: 72611 ALPENA 30 records starting with: 80018 AURORA 6 records starting with: 97103 ASTORIA The number of pages can be obtained from: $pages = int(($limited->execute( 'A%A', 0, -1), $limited->rows)/$pagelines) + ($limited->rows % $pagelines | 0 ? 1 : 0); This is a ceil() function, it acts like int but rounds up. =cut