Data::Paginator(3pm)
π Data::Paginator β pagination, but make it Moose π
okay bestie, so this is a page from the User Contributed Perl Documentation corner of your local man setup, and it's all about Data::Paginator. grab a snack, we're doing pagination π
β¨ NAME β¨
Data::Paginator β Pagination with Moose π¦
πΈ VERSION πΈ
version 0.08
π§ SYNOPSIS π§
use Data::Paginator;
my $pager = Data::Paginator->new(
current_page => 1,
entries_per_page => 10,
total_entries => 100,
);
print "First page: ".$pager->first_page."\n";
print "Last page: ".$pager->last_page."\n";
print "First entry on page: ".$pager->first."\n";
print "Last entry on page: ".$pager->last."\n";
likeβ¦ look at her. clean. composed. she knows exactly where every entry lives π
π DESCRIPTION π
okay so real talk: this is yet another pagination module. iconic behavior, honestly. it literally only exists because none of the other pager modules are written using Moose π
sometimes there's a Moose feature β MooseX::Storage, in the author's case β that you genuinely need, and it's a whole pain when you can't use it with an existing module. so this exists. she aims to be completely compatible with the venerable Data::Page. and not even in a sneaky way β it's a pretty blatant copy of Data::Page, lifting code from some of its methods. no cap, she said it herself π«Ά
π SETS π
this module provides behavior compatible with Data::PageSet, which means you can break your pagination into sets β¨
so like, imagine you've got a huge number of pages to show and you want the user to be able to 'jump' X pages at a time. you set the pages_per_set attribute to X and populate the links in your pagination control with the values from previous_set and next_set. boom. sets. slay π
π ATTRIBUTES π
β current_page
the current page. defaults to 1 π
if you set this value to a page number lesser than or greater than the range of the pager, then 1 or the last_page will be returned instead. so it is safe to pass in numbers like -1000 or 1000 when there are only 3 pages. she will not let you embarrass yourself bestie π
β entries_per_page
the number of entries per page. required at instantiation β no entry-per-page, no pager, periodt.
β last_page
returns the number of the last page. it's lazily computed, so do not set it. she computes herself, thank you π
β next_set
returns the number of the next set, or undef if there is no next. πΈ
β pages_per_set
if you've got a large number of pages to show and would like to let the user 'jump' X pages at a time, you set the pages_per_set attribute to X and populate the links in your pagination control with the values from previous_set and next_set. same energy as the SETS section, and yes she's saying it twice because it's important π
β previous_set
returns the set number of the previous set, or undef if there is no previous set. π¦
β total_entries
the total number of entries this pager is covering. required at instantiation fr fr.
β first
returns the number of the first entry on the current page β¨
β first_page
always returns 1. she's consistent. she's reliable. she's the moment π
π METHODS π
π entries_on_this_page
returns the number of entries on this page.
π first_set
returns 1 if this Paginator has pages_per_set. otherwise returns undef.
π last
returns the number of the last entry on the current page.
π next_page
returns the page number of the next page if one exists, otherwise returns false.
π page_for ($count)
returns the page number that the $count item appears on. returns undef if $count is outside the bounds of this Paginator.
π previous_page
returns the page number of the previous page if one exists, otherwise returns undef.
π set_for $page
returns the set number of the specified page. returns undef if the page exceeds the bounds of the Paginator.
π splice
takes in an arrayref and returns only the values which are on the current page. like a little filter, but make it pagination π
π ACKNOWLEDGEMENTS π
LΓ©on Brocard and his work on Data::Page. π«Ά
π AUTHOR π
Cory G Watson <gphat@cpan.org>
π COPYRIGHT AND LICENSE π
This software is copyright (c) 2014 by Cory G Watson.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
okay that's the whole page bestie, you ate it π
β¨ this was Data::Paginator as documented for perl v5.34.0, dated 2022-06-12, and she's filed under Data::Paginator(3pm) β go paginate something iconic, mwah πππ¦
π¦ where this page comes from
- debian bookworm: libdata-paginator-perl 0.08-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libdata-paginator-perl 0.08-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libdata-paginator-perl 0.08-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libdata-paginator-perl 0.08-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libdata-paginator-perl 0.08-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms