X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2Fabbrev.pl;h=c505a6f28bd7bb79152fd90fc57fd0e6cbf83f0c;hb=dd5ea221bb13f4bad856ba91d1a82acf3ec12919;hp=5859a7be48d8f0376fe231b94b8557c86d6d742c;hpb=a687059cbaf2c6fdccb5e0fae2aee80ec15625a8;p=p5sagit%2Fp5-mst-13.2.git diff --git a/lib/abbrev.pl b/lib/abbrev.pl index 5859a7b..c505a6f 100644 --- a/lib/abbrev.pl +++ b/lib/abbrev.pl @@ -4,19 +4,30 @@ ;# ... ;# $long = $foo{$short}; +# +# This library is no longer being maintained, and is included for backward +# compatibility with Perl 4 programs which may require it. +# +# In particular, this should not be used as an example of modern Perl +# programming techniques. +# +# Suggested alternative: Text::Abbrev +# + package abbrev; sub main'abbrev { local(*domain) = @_; shift(@_); @cmp = @_; + local($[) = 0; foreach $name (@_) { @extra = split(//,$name); $abbrev = shift(@extra); $len = 1; foreach $cmp (@cmp) { next if $cmp eq $name; - while (substr($cmp,0,$len) eq $abbrev) { + while (@extra && substr($cmp,0,$len) eq $abbrev) { $abbrev .= shift(@extra); ++$len; }