well, it is something you can easily do with 2 DB queries (one using LIMIT and a start/end pair -- or even just a start and calculate the end) passed into the application.
first query just gets the number of rows, second gets the limit .. and use the results of the first divided by the number of elements per page, and you have the number of pages.
process that number of pages as needed per templating system. i generate an array of hashrefs to pass into HTML::Template for stuff i've been doing recently. it's been a while since i've used Template::Toolkit.