.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Data::Pager 3pm" .TH Data::Pager 3pm "2021-01-07" "perl v5.32.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Data::Pager \- flexible data pager .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use Data::Pager; \& \& my $pager = Data::Pager\->new({ \& current => 100, \& perpage => 10, \& offset => 5, \& limit => 2000, \& }); \& \& #~ accessors: \& $pager\->current; # 100 \& $pager\->next; # 101 \& $pager\->prev; # 99 \& $pager\->limit; # 2000 \& $pager\->start; # 1 # not typical start of a programmer \& $pager\->final; # \e \& # 400 (which denotes 2000 / 5 pager links) \& $pager\->end; # / \& $pager\->from; # 495 (may serve in SQL LIMIT clause) \& $pager\->to; # 500 (may serve in SQL LIMIT clause) \& $pager\->list; # 95 96 97 98 99 100 101 102 103 104 105 .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This class implements the familiar pager where the current position is centered. .SH "CONSTRUCTOR" .IX Header "CONSTRUCTOR" .SS "new" .IX Subsection "new" .Vb 6 \& my $pager = Data::Pager\->new({ \& current => 1, # this is the current pager position \& perpage => 10, # the pager consists of this number of links (defaults to 10) \& offset => 5, # this is the number of results (fetched from the DB for example) per result \& limit => 100, # how far is the pager allowed \& }); \& \& # sample output from html table: \& \& id ... ..... ... \& 1. ... ..... ... \& 2. ... ..... ... \& 3. ... ..... ... \& 4. ... ..... ... \& 5. ... ..... ... \& \& 1 2 3 4 5 6 7 8 9 10 .Ve .PP Returns object or undef if current position is beyond the limit. .SH "METHODS" .IX Header "METHODS" .SS "current" .IX Subsection "current" .Vb 1 \& $pager\->current(); .Ve .PP Returns the current pager position. .SS "set_current($digit)" .IX Subsection "set_current($digit)" .Vb 2 \& $pager\->set_current(850); \& $pager\->set_current(850)\->next(); .Ve .PP Sets the current pager position. Returns the pager object on succes, undef on false. .SS "next" .IX Subsection "next" Returns the next pager position or undef if this is the last one. .SS "prev" .IX Subsection "prev" Returns the previous pager position or undef if this is the first one. .SS "start" .IX Subsection "start" Returns 1 \- the start pager position. .SS "end" .IX Subsection "end" Returns the end pager position. .SS "first" .IX Subsection "first" Returns the first pager position for this result set. .SS "last" .IX Subsection "last" Returns the last pager position for this result set. .SS "from" .IX Subsection "from" .Vb 10 \& \*(Aq1\*(Aq => { \& \*(Aqto\*(Aq => 5, \& \*(Aqnext\*(Aq => 2, \& \*(Aqprev\*(Aq => undef, \& \*(Aqfrom\*(Aq => 0 \& }, \& \*(Aq2\*(Aq => { \& \*(Aqto\*(Aq => 10, \& \*(Aqnext\*(Aq => 3, \& \*(Aqprev\*(Aq => 1, \& \*(Aqfrom\*(Aq => 5 \& }, \& ... .Ve .PP Returns the start result this pager position refers to. .SS "to" .IX Subsection "to" Returns the end result this pager position refers to. .SS "list" .IX Subsection "list" .Vb 2 \& @_ = $pager\->list; \& $_ = $pager\->list; .Ve .PP Returns the pager links for this result set. In list context returns the resulting list. In scalar context returns reference to the resulting list. .PP .Vb 1 \& # note the alignment \& \& $pager\->set_current(10); \& print $pager\->list; # 6 7 8 9 [10] 11 12 13 14 15 \& $pager\->set_current(33); \& print $pager\->list; # 28 29 30 31 32 [33] 34 35 36 37 38 .Ve .SH "SEE ALSO" .IX Header "SEE ALSO" Data::Page .SH "BUGS" .IX Header "BUGS" What \s-1BUGS\s0? .SH "AUTHOR" .IX Header "AUTHOR" Vidul Nikolaev Petrov, vidul@cpan.org .SH "COPYRIGHT" .IX Header "COPYRIGHT" This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. .PP The full text of the license can be found in the \&\s-1LICENSE\s0 file included with this module.