X-Git-Url: http://git.shiar.net/perl/list-index.git/blobdiff_plain/cbd8812884e40f965709d50f5e5b0a7bc1fd97b3..1c331324738bb8ca05889f1a7baa5e1b40595d38:/lib/List/Index.pm diff --git a/lib/List/Index.pm b/lib/List/Index.pm index 5b46313..4a21189 100644 --- a/lib/List/Index.pm +++ b/lib/List/Index.pm @@ -28,9 +28,9 @@ sub ranges { while ($offset < @$self) { my $link = substr $self->[$offset], 0, $length; if ($context) { - { + if ($offset > $context - 1) { # take a value slightly before the current offset - my $before = $offset > $context ? $self->[$offset - $context] : '.'; + my $before = $self->[$offset - $context - 1]; # see how much of it matches the current link my $trim = 1; for my $match (split //, $before) {