[Chapter 7] 7.2.65 Term::Complete - Word Completion Module
Author: Larry Wall, Tom Christiansen & Randal L. Schwartz
Date: 1999-07-02T02:04:23Z

#

| Chapter 7 The Standard Perl Library |

### 7.2.65 Term::Complete - Word Completion Module

    use Term::Complete;

    $input = Complete('prompt_string', \@completion_list);
    $input = Complete('prompt_string', @completion_list);

The `Complete()` routine sends the indicated prompt string to the currently selected filehandle, reads the user's response, and places the response in `$input`. What the user types is read one character at a time, and certain characters result in special processing as follows:

TAB

  The tab character causes `Complete()` to match what the user has typed so far against the list of strings in `@completion_list`. If the user's partial input uniquely matches one of these strings, then the rest of the matched string is output. However, input is still not finished until the user presses the return key. If the user's partial input does not uniquely match one string in `@completion_list` when the tab character is pressed, then the partial input remains unchanged and the bell character is output.

CTRL-D

  If the user types CTRL-D, the current matches between the user's partial input string and the completion list are printed out. If the partial input string is null, then the entire completion list is printed. In any case, the prompt string is then reissued, along with the partial input. You can substitute a different character for CTRL-D by defining `$Term::Complete::complete`. For example:

      $Term::Complete::complete = "\001";  # use ctrl-a instead of ctrl-d

CTRL-U

  Typing CTRL-U erases any partial input. You can substitute a different character for CTRL-U by defining `$Term::Complete::kill`.

DEL, BS

  The delete and backspace characters both erase one character from the partial input string. You can redefine them by assigning a different character value to `$Term::Complete::erase1` and `$Term::Complete::erase2`.

The user is not prevented from providing input that differs from all strings in the completion list, or from adding to input that has been completed from the list. The final input (determined when the user presses the return key) is the string returned by `Complete()`.

The TTY driver is put into raw mode using the system command `stty raw -echo` and restored using `stty -raw echo`. When `Complete()` is called multiple times, it offers the user's immediately previous response as the default response to each prompt.

7.2.64 Term::Cap - Terminal Capabilities Interface |  | 7.2.66 Test::Harness - Run Perl Standard Test Scripts with Statistics