Commit | Line | Data |
---|---|---|
a687059c LW |
1 | ;# Usage: |
2 | ;# %foo = (); | |
3 | ;# &abbrev(*foo,LIST); | |
4 | ;# ... | |
5 | ;# $long = $foo{$short}; | |
6 | ||
a6d71656 GS |
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 S |
10 | # This legacy library is deprecated and will be removed in a future |
11 | # release of perl. | |
a6d71656 GS |
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 LW |
19 | package abbrev; |
20 | ||
21 | sub main'abbrev { | |
22 | local(*domain) = @_; | |
23 | shift(@_); | |
24 | @cmp = @_; | |
25 | foreach $name (@_) { | |
26 | @extra = split(//,$name); | |
27 | $abbrev = shift(@extra); | |
28 | $len = 1; | |
29 | foreach $cmp (@cmp) { | |
30 | next if $cmp eq $name; | |
55497cff | 31 | while (@extra && substr($cmp,0,$len) eq $abbrev) { |
a687059c LW |
32 | $abbrev .= shift(@extra); |
33 | ++$len; | |
34 | } | |
35 | } | |
36 | $domain{$abbrev} = $name; | |
37 | while ($#extra >= 0) { | |
38 | $abbrev .= shift(@extra); | |
39 | $domain{$abbrev} = $name; | |
40 | } | |
41 | } | |
42 | } | |
43 | ||
44 | 1; |