1;# Usage:
2;#	%foo = ();
3;#	&abbrev(*foo,LIST);
4;#	...
5;#	$long = $foo{$short};
6
7#
8# This library is no longer being maintained, and is included for backward
9# compatibility with Perl 4 programs which may require it.
10#
11# In particular, this should not be used as an example of modern Perl
12# programming techniques.
13#
14# Suggested alternative: Text::Abbrev
15#
16
17package abbrev;
18
19sub main'abbrev {
20    local(*domain) = @_;
21    shift(@_);
22    @cmp = @_;
23    foreach $name (@_) {
24	@extra = split(//,$name);
25	$abbrev = shift(@extra);
26	$len = 1;
27	foreach $cmp (@cmp) {
28	    next if $cmp eq $name;
29	    while (@extra && substr($cmp,0,$len) eq $abbrev) {
30		$abbrev .= shift(@extra);
31		++$len;
32	    }
33	}
34	$domain{$abbrev} = $name;
35	while ($#extra >= 0) {
36	    $abbrev .= shift(@extra);
37	    $domain{$abbrev} = $name;
38	}
39    }
40}
41
421;
43