Term::ReadLine::Tiny - Read a line from STDIN.
Version 0.010_05
use Term::ReadLine::Tiny; my $new = Term::ReadLine::Tiny->new( 'name' ); my $line = $new->readline( 'Prompt: ', { default => 'abc' } );
readline reads a line from STDIN. As soon as Return is pressed readline returns the read string without the newline character - so no chomp is required.
readline
Return
chomp
BackSpace or Strg-H: Delete the character behind the cursor.
BackSpace
Strg-H
Delete or Strg-D: Delete the character at point. Return nothing if the input puffer is empty.
Delete
Strg-D
Strg-U: Delete the text backward from the cursor to the beginning of the line.
Strg-U
Strg-K: Delete the text from the cursor to the end of the line.
Strg-K
Right-Arrow or Strg-F: Move forward a character.
Right-Arrow
Strg-F
Left-Arrow or Strg-B: Move back a character.
Left-Arrow
Strg-B
Home or Strg-A: Move to the start of the line.
Home
Strg-A
End or Strg-E: Move to the end of the line.
End
Strg-E
The new method returns a Term::ReadLine::Tiny object.
new
Term::ReadLine::Tiny
my $new = Term::ReadLine::Tiny->new( 'name' );
The argument is the name of the application.
The method config sets the defaults for the current Term::ReadLine::Tiny object.
config
$new->config( \%options );
The available options are:
default
Sets the default default string.
Allowed values: a decoded string.
Default: not set.
no_echo
Sets the default value for no_echo.
Allowed values: 0, 1 or 2.
Default: 0.
Options not available in the readline method:
compat
If compat is set to 1, the return value of readline is not decoded else the return value of readline is decoded.
Setting the environment variable READLINE_TINY_COMPAT to a true value has the same effect as setting compat to 1 unless compat is defined. If compat is defined, READLINE_TINY_COMPAT has no meaning.
Allowed values: 0 or 1.
Default: no set
reinit_encoding
To get the right encoding Term::ReadLine::Tiny uses Encode::Locale. Passing an encoding to reinit_encoding changes the encoding reported by Encode::Locale. See "reinit-encoding" in Encode::Locale for more details.
Encode::Locale
Allowed values: an encoding which is recognized by the Encode module.
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 if it is not a reference. If the second argument is a hash-reference, the hash is used to set the different options. The keys/options are
Sets a initial value of input.
If no_echo is set to 1, "*" are displayed instead of the characters.
*
If no_echo is set to 2, no output is shown apart from the prompt string.
See "config" for the default and allowed values.
Requires Perl version 5.08.0 or greater.
It is required a terminal which uses a monospaced font and understands 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::ReadLine::Tiny
Matthäus Kiem <cuer2s@gmail.com>
Thanks to the Perl-Community.de and the people form stackoverflow for the help.
Copyright 2014 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::ReadLine::Tiny, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Term::ReadLine::Tiny
CPAN shell
perl -MCPAN -e shell install Term::ReadLine::Tiny
For more information on module installation, please visit the detailed CPAN module installation guide.