my $offset ||= 0; my $max = 100; my $sth = $dbh->prepare("SELECT ... LIMIT ?,?"); $sth->execute($offset, $limit);