3 # This library is no longer being maintained, and is included for backward
4 # compatibility with Perl 4 programs which may require it.
5 # This legacy library is deprecated and will be removed in a future
8 # In particular, this should not be used as an example of modern Perl
9 # programming techniques.
11 # Suggested alternative: Term::Complete
13 warn( "The 'complete.pl' legacy library is deprecated and will be"
14 . " removed in the next major release of perl. Please use the"
15 . " Term::Complete module instead." );
17 ;# @(#)complete.pl,v1.1 (me@anywhere.EBay.Sun.COM) 09/23/91
19 ;# Author: Wayne Thompson
22 ;# This routine provides word completion.
23 ;# (TAB) attempts word completion.
24 ;# (^D) prints completion list.
25 ;# (These may be changed by setting $Complete'complete, etc.)
28 ;# Bell when word completion fails.
31 ;# The tty driver is put into raw mode.
36 ;# $input = &Complete('prompt_string', *completion_list);
38 ;# $input = &Complete('prompt_string', @completion_list);
53 local($prompt, @cmp_list, $return, @match, $l, $test, $cmp, $r);
54 if ($_[1] =~ /^StB\0/) {
62 system('stty raw -echo');
64 print($prompt, $return);
65 while (($_ = getc(STDIN)) ne "\r") {
67 # (TAB) attempt completion
69 @match = grep(/^$return/, @cmp_lst);
70 $l = length($test = shift(@match));
71 unless ($#match < 0) {
72 foreach $cmp (@match) {
73 until (substr($cmp, 0, $l) eq substr($test, 0, $l)) {
79 print($test = substr($test, $r, $l - $r));
80 $r = length($return .= $test);
84 # (^D) completion list
85 $_ eq $complete && do {
86 print(join("\r\n", '', grep(/^$return/, @cmp_lst)), "\r\n");
101 # (DEL) || (BS) erase
102 ($_ eq $erase1 || $_ eq $erase2) && do {
121 system('stty -raw echo');