7 abbrev - create an abbreviation table from a list
17 Stores all unambiguous truncations of each element of LIST
18 as keys key in the associative array referenced to by C<$hashref>.
19 The values are the original list elements.
23 $hashref = abbrev qw(list edit send abort gripe);
25 %hash = abbrev qw(list edit send abort gripe);
27 abbrev $hashref, qw(list edit send abort gripe);
29 abbrev(*hash, qw(list edit send abort gripe));
39 # $long = $foo{$short};
43 my ($name, $ref, $glob);
45 if (ref($_[0])) { # hash reference preferably
47 } elsif ($_[0] =~ /^\*/) { # looks like a glob (deprecated)
53 my @extra = split(//,$name);
54 my $abbrev = shift(@extra);
57 WORD: foreach $cmp (@cmp) {
58 next if $cmp eq $name;
59 while (substr($cmp,0,$len) eq $abbrev) {
60 last WORD unless @extra;
61 $abbrev .= shift(@extra);
65 $domain{$abbrev} = $name;
67 $abbrev .= shift(@extra);
68 $domain{$abbrev} = $name;
74 } elsif ($glob) { # old style
75 local (*hash) = $glob;