in reply to HTML::Template/Pager or both?

Just to tell you up front, I've never used HTML::Pager, but it looks easy enough, and I use HTML::Template regularly.

HTML::Pager only wants (in the end) the set of data to be displayed in the template. What I would do is get your @files array, then define the H::P callback function so it will only get extended info for the relevant items that are to be displayed on the page. Some code: (UNTESTED)

my $get_data_sub = sub { my ($offset, $rows) = @_; my @return_array; my $sth = $dbh->prepare('SELECT id, title FROM resource WHER +E id = ?'); for (my $x = 0; $x < $rows; $x++) { my $filename = substr($files[$offset + $x], 0, -4); $sth->execute($filename); # Note I assume that the ID is unique (no need for a while loo +p - only # one record will be returned) otherwise the paging really doe +sn't work. $ref = $sth->fetchrow_hashref(); push @return_array, { ID => $ref->{id}, TITLE => $ref->{title} }; $sth->finish; } return \@return_array; }

That's a start, anyway. You'll have to make your H::P template know that it has named vars for each line (TITLE and ID). I would also change the sub so that it takes more args (like the @items array and the $dbh database handler) so you don't have to reference global vars.

HTH

Update: Moved the $dbh->prepare(...) out of the loop.

--
"To err is human, but to really foul things up you need a computer." --Paul Ehrlich