The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.


Data::Pageset::Variable - Variable results on each page of results.


        use Data::Pageset::Variable;
                # As Data::Pageset except...

        my $page_info = Data::Pageset->new(
                        total_entries              => $total_entries, 
                        variable_entries_per_page  => { 1 => 30, 2 => 20, 3 => 10, } 
                        entries_per_page           => 10,


Data::Pageset is A Great Module, and totally useful. This is a subclass that extends its behaviour.

Data::Pageset returns an object with a set number of pages per set. The point of Data::Pageset::Variable is that you might not want this to be so. You might, for reasons best known to yourself, want to have twice the number of results on the first page as on the second, and so on.

So now you can!


 Different numbers
 Of results on each page helps
 Tabulate results

This arose as Tony ( suggested to me that if I can't write the documentation of a module in haiku, then it is doing too many things. As I (also) believe that modules should be responsible for one concept, and one only.

Also, I have no poetical ability, so forgive my clumsy attempt.



        # In the constructor hashref...
                variable_entries_per_page => { 1 => 30, 2 => 20, 3 => 10, },

The variable_entries_per_page argument takes a hashref.

The key/value pairs of this hashref are the pages and the number of entries on the page. If there is a page for which none is specified, then we use the value of default_entries_per_page.

If this isn't set, then we behave exactly like Data::Pageset.


        # In the constructor hashref...  
                entries_per_page => 10,

This must be set. It is not optional. This is the number of entries per page for all pages which aren't specified in the entries_per_page hashref.


There was a thread on mailing list about working in a vacumn - that it was a bit depressing to keep writing modules but never get any feedback. So, if you use and like this module then please send me an email and make my day.

All it takes is a few little bytes.

(Leon wrote that, not me!)


Stray Toaster, <>

With Thanks

Leo for Data::Pageset. It rocks. (And also for a code suggestion, and taking the time to even look at this!)


Copyright 2003 by Stray Toaster

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.