[inseparable changes from patch from perl5.003_18 to perl5.003_19]
[p5sagit/p5-mst-13.2.git] / lib / Text / Abbrev.pm
index 893f3b1..ae6797c 100644 (file)
@@ -54,10 +54,11 @@ sub abbrev {
        my $abbrev = shift(@extra);
        my $len = 1;
         my $cmp;
-       foreach $cmp (@cmp) {
+       WORD: foreach $cmp (@cmp) {
            next if $cmp eq $name;
            while (substr($cmp,0,$len) eq $abbrev) {
-               $abbrev .= shift(@extra);
+                last WORD unless @extra;
+                $abbrev .= shift(@extra);
                ++$len;
            }
        }