my $pages = $options->{pages } || 1 + int $#rows / $pagesize;
$pagesize = $pages >= $#rows ? 1 : @rows / $pages;
my $pages = $options->{pages } || 1 + int $#rows / $pagesize;
$pagesize = $pages >= $#rows ? 1 : @rows / $pages;
my @links = ('');
for (my $offset = $pagesize + .5; $offset < @rows; $offset += $pagesize) {
my $link = substr $rows[$offset], 0, $length;
if ($context) {
my @links = ('');
for (my $offset = $pagesize + .5; $offset < @rows; $offset += $pagesize) {
my $link = substr $rows[$offset], 0, $length;
if ($context) {
# take a value slightly before the current offset
if ((my $before = $offset + $lookbehind) > 0) {
# see how much of it matches the current link
# take a value slightly before the current offset
if ((my $before = $offset + $lookbehind) > 0) {
# see how much of it matches the current link
# truncate link upto where the earlier value starts to differ
if ($trim < length $link) {
substr($link, $trim) = '';
# truncate link upto where the earlier value starts to differ
if ($trim < length $link) {
substr($link, $trim) = '';
# take a value after the current offset
if ((my $after = $offset + $lookahead) < $#rows) {
# see how much of it matches the current link
# take a value after the current offset
if ((my $after = $offset + $lookahead) < $#rows) {
# see how much of it matches the current link
if ($trim < length $link) {
$link = substr $rows[$after], 0, $trim;
# advance lookbehind offset on the next page
if ($trim < length $link) {
$link = substr $rows[$after], 0, $trim;
# advance lookbehind offset on the next page