in reply to Printing Table of Contents From an Array On Multiple Pages

G'day Milti,

"... (I know how to do that) but wish to limit the number of items per page to 10 while including a footer saying next page or whatever. How do I do that?"

The logic for that is fairly straightforward. Using less filenames and shorter pages for demo purposes:

$ perl -Mstrict -Mwarnings -E ' my @files = "A" .. "J"; my $items_per_page = 3; my $current_item = 0; for (@files) { say; if (not ++$current_item % $items_per_page) { say "Next Page" unless $current_item == @files; } } ' A B C Next Page D E F Next Page G H I Next Page J

In case you were wondering, 'unless $current_item == @files' stops the "Next Page" message being output when the end of page coincides with the end of data. Using one less file:

$ perl -Mstrict -Mwarnings -E ' my @files = "A" .. "I"; my $items_per_page = 3; my $current_item = 0; for (@files) { say; if (not ++$current_item % $items_per_page) { say "Next Page" unless $current_item == @files; } } ' A B C Next Page D E F Next Page G H I

-- Ken