NAME Data::Page::Flexible - A data pager that allows a flexible number of entries per page. VERSION This document describes Data::Page::Flexible version 0.0.1 SYNOPSIS use Data::Page::Flexible; my $pager = Data::Page::Flexible->new({ total_entries => 67, entries_per_page => 25 }); print $pager->last_page() # 2 print $pager->entries_per_page() # 34 DESCRIPTION This module behaves like Data::Page except that it allows the number of entries per page to be flexible. If, for example, you have 26 entries and want 25 entries per page, a normal pager would give you two pages with 25 entries on the first and 1 on the last. Data::Page::Flexible will instead give you one page with 26 entries. The benefit of a flexible number of entries per page is greater when the number of pages is small, with the ideal case being when there are two pages with only one entry on the last. This saves the user from having to navigate to a page with only one entry, making it easier for him or her to see all the entries at once. The default flexibility is "floor(entries_per_page/2)", which means that in the example with 25 entries per page, the calculated entries per page can go up to 37 (25 + 12). The flexibility can be changed both at initialization and later on. INTERFACE new my $pager = Data::Page::Flexible->new({ total_entries => 67, entries_per_page => 25 }); This constructs a new pager object. The "total_entries" and "entries_per_page" arguments are mandatory, since they are used to calculate the actual number of entries per page. You can optionally also specify the "current_page" and "flexibility" arguments. All arguments are given as name-value pairs in an anonymous hash. total_entries $pager->total_entries(100); # Sets the total entries to 100 $pager->total_entries(); # Returns the current total entries This will get or set the total entries. *Changing this will re-calculate the number of entries per page.* entries_per_page $pager->entries_per_page(23); # Sets the entries per page to 23 $pager->entries_per_page(); # Returns the current entries per page This will get or set the entries per page. *Since changing this will re-calculate the number of entries per page according to the flexibility, in most cases what you set is not what you later will get.* flexibility $pager->flexibility(12); # Sets the flexibility to 12 $pager->flexibility(); # Returns the current flexibility This will get or set the flexibility value. *Changing this will re-calculate the number of entries per page.*