a -argv Prompt for data if Immediately fail if input char smartmatches value Either use the long form of these options, or bundle them with another option, or add a "no-op" to them. Note: For options preceded by an asterisk, the short form is actually a Perl file operator, and hence cannot be used by itself. In such cases, just use the long form of the option (for example: -def => 'efault' or -default=>'$%^!'). Note that this implies that short-form options may not be able to specify every possible associated value (for example, the short-form -d option cannot specify defaults with values 'efault' or '$%^!'). The associated value for long-form options is always specified as a separated argument, immediately following the option (typically separated from it by a =>). For short-form options, this value is specified as a string appended to the option itself. The short form is always the first letter of the long form. INTERFACEĪll the options for prompt() start with a hyphen ( -). Hence, it is designed to be a drop-in replacement for readline or. The prompt() function also sets $_ if it is called in a boolean context but its return value is not assigned to a variable. See "Useful useless uses of prompt()" for an exception to this. 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. # (some of which may be failure objects). even on failure), prefix the call with scalar: # Only produces as many elements If you particularly need a list-context call to prompt() to always return a value (i.e. This allows failures in list context to behave correctly (i.e. In list contexts, if the input operation fails prompt() returns an empty list instead of a return object. In scalar boolean contexts this return object evaluates true if the input operation succeeded. Normally, when prompt() is called in either list or scalar context, it returns an opaque object that autoconverts to a string. If no prompt string is provided, the string '> ' is used instead. All such arguments are concatenated together before the prompt is issued. See "Summary of options" and "Options reference" for details of the available options.Īny other argument that is a string is treated as (part of) the prompt to be displayed. The prompt() subroutine expects zero-or-more arguments.Īny 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). IO::Prompter 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. See "Returning raw data" to turn off this (occasionally counter-intuitive) behaviour. This means that the object evaluates true even when the input value is zero or an empty string. This object always evaluates true in boolean contexts, unless the read operation actually failed. If using that platform, you may have more success (and less distress) by trying IO::Prompt::Tiny, IO::Prompt::Simple, or IO::Prompt::Hooked first.īy default the prompt() subroutine does not return a string it returns an object with overloaded string and boolean conversions. Several features of this module are known to have problems under Windows. = prompt 'Enter your password', -echo=>'*' This document describes IO::Prompter version 0.005001 SYNOPSIS use IO::Prompter IO::Prompter - Prompt for input, read it, clean it, return it.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |