Commit | Line | Data |
a687059c |
1 | ;# Usage: |
2 | ;# %foo = (); |
3 | ;# &abbrev(*foo,LIST); |
4 | ;# ... |
5 | ;# $long = $foo{$short}; |
6 | |
a6d71656 |
7 | # |
8 | # This library is no longer being maintained, and is included for backward |
9 | # compatibility with Perl 4 programs which may require it. |
8670a613 |
10 | # This legacy library is deprecated and will be removed in a future |
11 | # release of perl. |
a6d71656 |
12 | # |
13 | # In particular, this should not be used as an example of modern Perl |
14 | # programming techniques. |
15 | # |
16 | # Suggested alternative: Text::Abbrev |
17 | # |
18 | |
a687059c |
19 | package abbrev; |
20 | |
8670a613 |
21 | warn( "The 'abbrev.pl' legacy library is deprecated and will be" |
22 | . " removed in the next major release of perl. Please use the" |
23 | . " Text::Abbrev module instead." ); |
24 | |
a687059c |
25 | sub main'abbrev { |
26 | local(*domain) = @_; |
27 | shift(@_); |
28 | @cmp = @_; |
449aadca |
29 | local($[) = 0; |
a687059c |
30 | foreach $name (@_) { |
31 | @extra = split(//,$name); |
32 | $abbrev = shift(@extra); |
33 | $len = 1; |
34 | foreach $cmp (@cmp) { |
35 | next if $cmp eq $name; |
55497cff |
36 | while (@extra && substr($cmp,0,$len) eq $abbrev) { |
a687059c |
37 | $abbrev .= shift(@extra); |
38 | ++$len; |
39 | } |
40 | } |
41 | $domain{$abbrev} = $name; |
42 | while ($#extra >= 0) { |
43 | $abbrev .= shift(@extra); |
44 | $domain{$abbrev} = $name; |
45 | } |
46 | } |
47 | } |
48 | |
49 | 1; |