This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Fix ext/XS-APItest/t/multicall.t warning
[perl5.git] / lib / abbrev.pl
1 warn "Legacy library @{[(caller(0))[6]]} will be removed from the Perl core distribution in the next major release. Please install it from the CPAN distribution Perl4::CoreLibs. It is being used at @{[(caller)[1]]}, line @{[(caller)[2]]}.\n";
2
3 ;# Usage:
4 ;#      %foo = ();
5 ;#      &abbrev(*foo,LIST);
6 ;#      ...
7 ;#      $long = $foo{$short};
8
9 #
10 # This library is no longer being maintained, and is included for backward
11 # compatibility with Perl 4 programs which may require it.
12 # This legacy library is deprecated and will be removed in a future
13 # release of perl.
14 #
15 # In particular, this should not be used as an example of modern Perl
16 # programming techniques.
17 #
18 # Suggested alternative: Text::Abbrev
19 #
20
21 package abbrev;
22
23 sub main'abbrev {
24     local(*domain) = @_;
25     shift(@_);
26     @cmp = @_;
27     foreach $name (@_) {
28         @extra = split(//,$name);
29         $abbrev = shift(@extra);
30         $len = 1;
31         foreach $cmp (@cmp) {
32             next if $cmp eq $name;
33             while (@extra && substr($cmp,0,$len) eq $abbrev) {
34                 $abbrev .= shift(@extra);
35                 ++$len;
36             }
37         }
38         $domain{$abbrev} = $name;
39         while ($#extra >= 0) {
40             $abbrev .= shift(@extra);
41             $domain{$abbrev} = $name;
42         }
43     }
44 }
45
46 1;