X-Git-Url: http://git.shiar.net/perl/list-index.git/blobdiff_plain/3e2d0470d99683367de89a9ad4569247d3897355..e5fa8cd7b5cc84943c5f7c32c4f34974613a235b:/lib/List/Index.pm diff --git a/lib/List/Index.pm b/lib/List/Index.pm index 06c2727..339bd7d 100644 --- a/lib/List/Index.pm +++ b/lib/List/Index.pm @@ -55,9 +55,10 @@ sub ranges { # use this link if it's shorter if ($trim < length $link) { $link = substr $after, 0, $trim; -# $offset += $context + 1; - $self->[$offset + ++$penalty] =~ /^\Q$link/ - while $offset + $penalty < $#$self; + for ($offset .. $#$self) { + last if $self->[$offset + $penalty] =~ /^\Q$link/; + $penalty++; + } } } }