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