This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Resort some perldiag entries
[perl5.git] / lib / abbrev.pl
CommitLineData
0111154e
Z
1warn "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
a687059c
LW
3;# Usage:
4;# %foo = ();
5;# &abbrev(*foo,LIST);
6;# ...
7;# $long = $foo{$short};
8
a6d71656
GS
9#
10# This library is no longer being maintained, and is included for backward
11# compatibility with Perl 4 programs which may require it.
8670a613
S
12# This legacy library is deprecated and will be removed in a future
13# release of perl.
a6d71656
GS
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
a687059c
LW
21package abbrev;
22
23sub 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;
55497cff 33 while (@extra && substr($cmp,0,$len) eq $abbrev) {
a687059c
LW
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
461;