Data::Page 2.00 review

Download
by rbytes.net on

Data::Page is a Perl module that helps when paging through sets of results. SYNOPSIS use Data::Page; my $page = Data::Pa

License: Perl Artistic License
File size: 6K
Developer: Leon Brocard
0 stars award from rbytes.net

Data::Page is a Perl module that helps when paging through sets of results.

SYNOPSIS

use Data::Page;

my $page = Data::Page->new();
$page->total_entries($total_entries);
$page->entries_per_page($entries_per_page);
$page->current_page($current_page);

print " First page: ", $page->first_page, "n";
print " Last page: ", $page->last_page, "n";
print "First entry on page: ", $page->first, "n";
print " Last entry on page: ", $page->last, "n";

When searching through large amounts of data, it is often the case that a result set is returned that is larger than we want to display on one page. This results in wanting to page through various pages of data. The maths behind this is unfortunately fiddly, hence this module.

The main concept is that you pass in the number of total entries, the number of entries per page, and the current page number. You can then call methods to find out how many pages of information there are, and what number the first and last entries on the current page really are.

For example, say we wished to page through the integers from 1 to 100 with 20 entries per page. The first page would consist of 1-20, the second page from 21-40, the third page from 41-60, the fourth page from 61-80 and the fifth page from 81-100. This module would help you work this out.

Requirements:
Perl

Data::Page 2.00 search tags