# create a callback subroutine to generate the data to be paged my $get_data_sub = sub { my ($offset, $rows) = @_; my @return_array; for (my $x = 0; $x < $rows; $x++) { push(@return_array, [ $row ]); } return \@return_array; } #### my $get_data_sub = sub { my ($offset, $rows) = @_; my @return_array; # Prepare SQL query: my $sth = $dbi->prepare("Your SQL here that fetches the data from $offset to $offset+$rows"); $sth->execute($offset, $rows); while (my $array_ref = $sth->fetchrow_arrayref){ push @return_array, $array_ref; } return \@return_array; }