X-Git-Url: http://git.shiar.net/gitweb.cgi/perl/list-index.git/blobdiff_plain/923bf7c029470b51452733cd1c17df0b1397e63b..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) {