+++: rangematch() fixes
[perl/list-index.git] / lib / List / Index.pm
index 6a818bb23ec78e766a0c808c52681a38260142ec..89fdc75c83fa3c7b8709734f6b0403aeee087048 100644 (file)
@@ -65,8 +65,8 @@ sub rangematch {
                        $c1 = substr $s1, $i, 1;
                        my $c2 = length $s2 <= $i ? undef : substr $s2, $i, 1;
                        my $next = $i + 1 >= length($s1) ? $c1 : chr( ord($c1) + 1 );
-                       $next le $c2 or next if defined $c2;
                        my $last = defined $c2 && $i == 0 ? chr( ord($c2) - (length $s2 > 1) ) : 'z';
+                       $next le $last or next if defined $c2;
                        push @allow, $prefix."[$next-$last]";
                }
                continue {