.\" Automatically generated by Pod::Man 4.07 (Pod::Simple 3.32) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .if !\nF .nr F 0 .if \nF>0 \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} .\} .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "IO::Prompt 3pm" .TH IO::Prompt 3pm "2016-11-25" "perl v5.24.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" IO::Prompt \- Interactively prompt for user input .SH "STATUS" .IX Header "STATUS" This module is no longer being maintained. .PP Use the IO::Prompter module instead. .SH "VERSION" .IX Header "VERSION" This document describes IO::Prompt version 0.997004 .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 4 \& use IO::Prompt; \& while( prompt "next: " ) { \& print "You said \*(Aq$_\*(Aq\en"; \& } .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" By default, this module exports a single function \f(CW\*(C`prompt\*(C'\fR. It prompts the user to enter some input, and returns an object that represents the user input. .PP You may specify various flags to the function to affect its behaviour; most notably, it defaults to automatically \f(CW\*(C`chomp\*(C'\fR the input, unless the \f(CW\*(C`\-line\*(C'\fR flag is specified. .PP Two other functions are exported at request: \f(CW\*(C`hand_print\*(C'\fR, which simulates hand-typing to the console; and \f(CW\*(C`get_input\*(C'\fR, which is the lower-level function that actually prompts the user for a suitable input. .PP Note that this is an interim re-release. A full release with better documentation will follow in the near future. Meanwhile, please consult the \fIexamples\fR directory from this module's \s-1CPAN\s0 distribution to better understand how to make use of this module. .SH "INTERFACE" .IX Header "INTERFACE" .ie n .SS "Arguments to ""prompt""" .el .SS "Arguments to \f(CWprompt\fP" .IX Subsection "Arguments to prompt" Any argument not of the following forms is treated as part of the text of the prompt itself. .PP .Vb 3 \& Flag Long form Arg Effect \& \-\-\-\- \-\-\-\-\-\-\-\-\- \-\-\- \-\-\-\-\-\- \& Use as prompt \& \& Prompt to specified filehandle \& \& Flatten hash entries into argument list \& (useful for aggregating the options below) \& \& \-p \-prompt Specify prompt explicitly \& \& \-s \-speed Simulated typing speed (seconds/char) \& \& \-e \-echo What to echo for each char typed \& \& \-nl \-newline When a newline is typed, echo instead \& \& \-d \-default What to return if only pressed \& \& \& \-r \-require Each value of each entry must \*(Aqsmartmatch\*(Aq \& the input else corresponding key is printed \& as error message: \& \- Subs must return true when passed input \& \- Regexes must pattern match input \& \- Strings must eq match input \& \- Arrays are flattened & recursively matched \& \- Hashes must return true for input as key \& \& \-u \-until Fail if input matches \& \-fail_if \& \& \-w \-while Fail unless input matches \& \-okay_if \& \& \-m \-menu Show the data specified as a menu \& and allow one to be selected. Enter \& an to back up one level. \& \& \-1 \-one_char Return immediately after first char typed \& \& \-x \-escape Pressing returns "\ee" immediately \& \& \-raw \-raw_input Return only the string that was input \& (turns off context\-sensitive features) \& \& \-c \-clear Clear screen before prompt \& \-f \-clear_first Clear screen before first prompt only \& \& \-a \-argv Load @ARGV from input if @ARGV empty \& \& \-l \-line Don\*(Aqt autochomp \& \& \-t \-tty Prompt to terminal no matter what \& \& \-y \-yes Return true if [yY] entered, false otherwise \& \-yn \-yes_no Return true if [yY], false if [nN] \& \-Y \-Yes Return true if \*(AqY\*(Aq entered, false otherwise \& \-YN \-Yes_No Return true if \*(AqY\*(Aq, false if \*(AqN\*(Aq \& \& \-num \-number Accept only valid numbers as input \& \-i \-integer Accept only valid integers as input .Ve .PP Note that the underscores between words in flags like \f(CW\*(C`\-one_char\*(C'\fR and \&\f(CW\*(C`\-yes_no\*(C'\fR are optional. .PP Flags can be \*(L"cuddled\*(R". For example: .PP .Vb 1 \& prompt("next: ", \-tyn1s=>0.2) # \-tty, \-yes, \-no, \-one_char, \-speed=>0.2 .Ve .ie n .SS """Hand-written"" printing via ""hand_print()""" .el .SS "``Hand-written'' printing via \f(CWhand_print()\fP" .IX Subsection "Hand-written printing via hand_print()" The \f(CW\*(C`hand_print()\*(C'\fR subroutine takes a string and prints it out in the stop-and-start manner of hand-typed text. .ie n .SS "Low-level input retrieval via ""get_input()""" .el .SS "Low-level input retrieval via \f(CWget_input()\fP" .IX Subsection "Low-level input retrieval via get_input()" The \f(CW\*(C`get_input()\*(C'\fR subroutine is a low-level utility subroutine that takes an input filehandle, an output filehandle, a reference to a hash of options (as listed for \f(CW\*(C`prompt()\*(C'\fR, above) and a single prompt string. It prints the prompt and retreives the input. You almost certainly want to use \f(CW\*(C`prompt()\*(C'\fR instead. .SH "DIAGNOSTICS" .IX Header "DIAGNOSTICS" .ie n .IP """Can\*(Aqt write prompt to read\-only $_""" 4 .el .IP "\f(CWCan\*(Aqt write prompt to read\-only $_\fR" 4 .IX Item "Cant write prompt to read-only $_" You specified a filehandle to which the prompt should be written, but that filehandle was not writeable. Did you pass the wrong filehandle, or open it in the wrong mode? .ie n .IP """Missing argument for %s option""" 4 .el .IP "\f(CWMissing argument for %s option\fR" 4 .IX Item "Missing argument for %s option" The flag you specified takes an argument, but you didn't provide that argument. .ie n .IP """Unknown flag ($s) in prompt""" 4 .el .IP "\f(CWUnknown flag ($s) in prompt\fR" 4 .IX Item "Unknown flag ($s) in prompt" The flag you specified wasn't one of those that \f(CW\*(C`prompt()\*(C'\fR understands. Did you misspell it, perhaps? .ie n .IP """Argument to \-require must be hash reference""" 4 .el .IP "\f(CWArgument to \-require must be hash reference\fR" 4 .IX Item "Argument to -require must be hash reference" The \f(CW\*(C`\-require\*(C'\fR option takes a single argument that is a hash. You tried to pass it something else. Try a hash instead. .ie n .IP """Cannot write to terminal: %s""" 4 .el .IP "\f(CWCannot write to terminal: %s\fR" 4 .IX Item "Cannot write to terminal: %s" .PD 0 .ie n .IP """Cannot read from terminal: %s""" 4 .el .IP "\f(CWCannot read from terminal: %s\fR" 4 .IX Item "Cannot read from terminal: %s" .PD \&\f(CW\*(C`prompt()\*(C'\fR attempted to access the terminal but couldn't. This may mean your environment has no \f(CW\*(C`/dev/tty\*(C'\fR available, in which case there isn't much you can do with this module. Sorry. .ie n .IP """Can\*(Aqt open %s: %s""" 4 .el .IP "\f(CWCan\*(Aqt open %s: %s\fR" 4 .IX Item "Cant open %s: %s" \&\f(CW\*(C`prompt()\*(C'\fR tried to read input via \f(CW*ARGV\fR from a file specified on the command-line, but the file couldn't be opened for the reason shown. This is usually either a permission problem, a non-existent file, or a mistyped filepath. .ie n .IP """Argument to \-menu must be hash or array reference""" 4 .el .IP "\f(CWArgument to \-menu must be hash or array reference\fR" 4 .IX Item "Argument to -menu must be hash or array reference" The \f(CW\*(C`\-menu\*(C'\fR option requires an argument that is either an array: .Sp .Vb 1 \& prompt \-menu=>[\*(Aqyes\*(Aq, \*(Aqno\*(Aq, \*(Aqmaybe\*(Aq]; .Ve .Sp or a hash: .Sp .Vb 1 \& prompt \-menu=>{yes=>1, no=>0, maybe=>0.5}; .Ve .Sp or a hash of hashes (of hashes (of array)) .ie n .IP """Too many \-menu items""" 4 .el .IP "\f(CWToo many \-menu items\fR" 4 .IX Item "Too many -menu items" .PD 0 .ie n .IP """Too few \-menu items""" 4 .el .IP "\f(CWToo few \-menu items\fR" 4 .IX Item "Too few -menu items" .PD A menu can't have fewer than 1 or more than 26 items. .SH "CONFIGURATION AND ENVIRONMENT" .IX Header "CONFIGURATION AND ENVIRONMENT" IO::Prompt requires no configuration files or environment variables. .SH "DEPENDENCIES" .IX Header "DEPENDENCIES" IO::Prompt requires the following modules: .IP "\(bu" 4 version .IP "\(bu" 4 IO::Handle .IP "\(bu" 4 Term::ReadKey .SH "INCOMPATIBILITIES" .IX Header "INCOMPATIBILITIES" The module requires a /dev/tty device be available. It is therefore incompatible with any system that doesn't provide such a device. .SH "BUGS AND LIMITATIONS" .IX Header "BUGS AND LIMITATIONS" No bugs have been reported. .PP Please report any bugs or feature requests to \&\f(CW\*(C`bug\-io\-prompt@rt.cpan.org\*(C'\fR, or through the web interface at . .SH "FAQ" .IX Header "FAQ" This is a collection of things that might help. Please send your questions that are not answered here to Damian Conway \&\f(CW\*(C`\*(C'\fR .SS "Can I use this module with ActivePerl on Windows?" .IX Subsection "Can I use this module with ActivePerl on Windows?" Up to now, the answer was 'No', but this has changed. .PP You still cannot use ActivePerl, but if you use the Cygwin environment (http://sources.redhat.com), which brings its own perl, and have the latest IO::Tty (v0.05 or later) installed, it should work (feedback appreciated). .SH "THANKS" .IX Header "THANKS" My deepest gratitude to Autrijus Tang and Brian Ingerson, who have taken care of this module for the past twelve months, while I was off trekking in the highlands of Perl 6. Now it's their turn for some mountain air, I'll be looking after this module again. .SH "AUTHOR" .IX Header "AUTHOR" Damian Conway \f(CW\*(C`\*(C'\fR .SH "LICENCE AND COPYRIGHT" .IX Header "LICENCE AND COPYRIGHT" Copyright (c) 2005, Damian Conway \f(CW\*(C`\*(C'\fR. All rights reserved. .PP This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. .SH "DISCLAIMER OF WARRANTY" .IX Header "DISCLAIMER OF WARRANTY" \&\s-1BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE \*(L"AS IS\*(R" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION.\s0 .PP \&\s-1IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE \s0(\s-1INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE\s0), \s-1EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.\s0