+++: numbers first
[perl/list-index.git] / lib / List / Index.pm
index c42db44eadb5be52310a3ec76b54df640eb06209..50e48a5eb30f71d6b3abaefe77bcbd2a09b9cfa7 100644 (file)
@@ -29,7 +29,7 @@ sub ranges {
                my $link = substr $self->[$offset], 0, $length;
                if ($context) {
                        my $trim = 1;
-                       my $before = $offset > $context ? $self->[$offset - $context] : '';
+                       my $before = $offset > $context ? $self->[$offset - $context] : '.';
                        for my $match (split //, $before) {
                                scalar $link =~ /\G\Q$match/g or last;
                                $trim++;
@@ -43,8 +43,8 @@ sub ranges {
 
        for my $i (0 .. $#links - 1) {
                my ($link, $lastchar) = $links[$i + 1]->[0] =~ /(.*)(.)/;
-               $link .= $lastchar eq '.' ? 'a' : chr( ord($lastchar) - 1 )
-                       unless $lastchar eq 'a';
+               $link .= $lastchar eq 'a' ? '.' : chr( ord($lastchar) - 1 )
+                       unless $lastchar eq '.';
                $links[$i]->[1] = $link;
        }
        $links[-1]->[1] = '';