IO::Prompter

Prompt for input, read it, clean it, return it
Download

IO::Prompter Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Publisher Name:
  • Damian Conway
  • Publisher web site:
  • http://search.cpan.org/~dconway/

IO::Prompter Tags


IO::Prompter Description

Prompt for input, read it, clean it, return it IO::Prompter is a Perl module that exports a single subroutine, prompt, that prints a prompt (but only if the program's selected input and output streams are connected to a terminal), then reads some input, then chomps it, and finally returns an object representing that text.The prompt() subroutine expects zero-or-more arguments.Any argument that starts with a hyphen (-) is treated as a named option (many of which require an associated value, that may be passed as the next argument). See "Summary of options" and "Options reference" for details of the available options.Any other argument that is a string is treated as (part of) the prompt to be displayed. All such arguments are concatenated together before the prompt is issued. If no prompt string is provided, the string '> ' is used instead.Normally, when prompt() is called in either list or scalar context, it returns an opaque object that autoconverts to a string. In scalar boolean contexts this return object evaluates true if the input operation succeeded. List boolean contexts present a special challenge (see the -verbatim option for details and a simple solution).In void contexts, prompt() still requests input, but also issues a warning about the general uselessness of performing an I/O operation whose results are then immediately thrown away. See "Useful useless uses of prompt()" for an exception to this.The prompt() function also sets $_ if it is called in a boolean context but its return value is not assigned to a variable. Hence, it is designed to be a drop-in replacement for readline or < >.SYNOPSIS use IO::Prompter; while (prompt -num 'Enter a number') { say "You entered: $_"; } my $passwd = prompt 'Enter your password', -echo=>'*'; my $selection = prompt 'Choose wisely...', -menu => { wealth => , health => , wisdom => , }, '>'; Requirements: · Perl


IO::Prompter Related Software