Term::Form::ReadLine - Read a line from STDIN.
Version 0.554
# Object-oriented interface: use Term::Form::ReadLine; my $new = Term::Form::ReadLine->new(); my $line = $new->readline( 'Prompt: ', { default => 'abc' } ); # Functional interface: use Term::Form::ReadLine qw( read_line ); my $line = read_line( 'Prompt: ', { default => 'abc' } );
readline reads a line from STDIN. As soon as Return is pressed, readline returns the read string without a trailing newline character.
readline
Return
The output is removed after leaving the method, so the user can decide what remains on the screen.
BackSpace or Ctrl-H: Delete the character behind the cursor.
BackSpace
Ctrl-H
Delete or Ctrl-D: Delete the character at point.
Delete
Ctrl-D
Ctrl-U: Delete the text backward from the cursor to the beginning of the line.
Ctrl-U
Ctrl-K: Delete the text from the cursor to the end of the line.
Ctrl-K
Right-Arrow or Ctrl-F: Move forward a character.
Right-Arrow
Ctrl-F
Left-Arrow or Ctrl-B: Move back a character.
Left-Arrow
Ctrl-B
Home or Ctrl-A: Move to the start of the line.
Home
Ctrl-A
End or Ctrl-E: Move to the end of the line.
End
Ctrl-E
Page-Up or Ctrl-P: Move back 10 characters.
Page-Up
Ctrl-P
Page-Down or Ctrl-N: Move forward 10 characters.
Page-Down
Ctrl-N
Ctrl-X: If the input puffer is not empty, the input puffer is cleared, else Ctrl-X returns nothing (undef).
Ctrl-X
Up-Arrow or Ctrl-S: History up.
Up-Arrow
Ctrl-S
Down-Arrow or Ctrl-T: History down.
Down-Arrow
Ctrl-T
The new method returns a Term::Form::ReadLine object.
new
Term::Form::ReadLine
my $new = Term::Form::ReadLine->new();
To set the different options it can be passed a reference to a hash as an optional argument.
readline reads a line from STDIN.
$line = $new->readline( $prompt, \%options );
The fist argument is the prompt string.
The optional second argument is the default string (see option default) if it is not a reference. If the second argument is a hash-reference, the hash is used to set the different options. The hash-keys/options are:
0 - clears from the current position to the end of screen
1 - clears the entire screen
2 - clears only the rows used by readline
default: 0
0
This option has only meaning if the operating system is MSWin32.
If the OS is MSWin32, Win32::Console::ANSI is used. By default Win32::Console::ANSI converts the characters from Windows code page to DOS code page (the so-called ANSI to OEM conversion). This conversation is disabled by default in Term::Choose, but one can enable it by setting this option.
Win32::Console::ANSI
Term::Choose
0 - disables the automatic codepage mapping (default)
1 - keeps the automatic codepage mapping
Enables the support for color and text formatting escape sequences for the prompt string and the info text.
0 - off
1 - on
Set a initial value of input.
0 - disabled
1 - enabled
default: 1
1
This option allows one to pass a readline history as a reference to an array.
If the entered string matches the beginning of one or more history entries, only these matched history entries are offered.
See "Keys" for how to move through the history.
default: empty
Expects as is value a string. If set, the string is printed on top of the output of readline.
0 - the input is echoed on the screen.
1 - "*" are displayed instead of the characters.
*
2 - no output is shown apart from the prompt string.
Display the input that does not fit into the "readline" before or after the "readline".
Requires Perl version 5.10.0 or greater.
It is required a terminal which uses a monospaced font.
Unless the OS is MSWin32 the terminal has to understand ANSI escape sequences.
It is required to use appropriate I/O encoding layers. If the encoding layer for STDIN doesn't match the terminal's character set, readline will break if a non ascii character is entered.
You can find documentation for this module with the perldoc command.
perldoc Term::Form::ReadLine
Matthäus Kiem <cuer2s@gmail.com>
Thanks to the Perl-Community.de and the people form stackoverflow for the help.
Copyright 2022-2023 Matthäus Kiem.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl 5.10.0. For details, see the full text of the licenses in the file LICENSE.
To install Term::Form, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Term::Form
CPAN shell
perl -MCPAN -e shell install Term::Form
For more information on module installation, please visit the detailed CPAN module installation guide.