{
    "mode": "perldoc",
    "parameter": "IO::Prompt",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/IO%3A%3APrompt/json",
    "generated": "2026-06-12T17:54:47Z",
    "synopsis": "use IO::Prompt;\nwhile( prompt \"next: \" ) {\nprint \"You said '$'\\n\";\n}",
    "sections": {
        "NAME": {
            "content": "IO::Prompt - Interactively prompt for user input\n",
            "subsections": []
        },
        "STATUS": {
            "content": "This module is no longer being maintained.\n\nUse the IO::Prompter module instead.\n",
            "subsections": []
        },
        "VERSION": {
            "content": "This document describes IO::Prompt version 0.997004\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "use IO::Prompt;\nwhile( prompt \"next: \" ) {\nprint \"You said '$'\\n\";\n}\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "By default, this module exports a single function \"prompt\". It prompts the user to enter some\ninput, and returns an object that represents the user input.\n\nYou may specify various flags to the function to affect its behaviour; most notably, it defaults\nto automatically \"chomp\" the input, unless the \"-line\" flag is specified.\n\nTwo other functions are exported at request: \"handprint\", which simulates hand-typing to the\nconsole; and \"getinput\", which is the lower-level function that actually prompts the user for a\nsuitable input.\n\nNote that this is an interim re-release. A full release with better documentation will follow in\nthe near future. Meanwhile, please consult the examples directory from this module's CPAN\ndistribution to better understand how to make use of this module.\n",
            "subsections": []
        },
        "INTERFACE": {
            "content": "Arguments to \"prompt\"\nAny argument not of the following forms is treated as part of the text of the prompt itself.\n\nFlag   Long form      Arg          Effect\n----   ---------      ---          ------\n<str>        Use <str> as prompt\n\n<filehandle> Prompt to specified filehandle\n\n<hashref>    Flatten hash entries into argument list\n(useful for aggregating the options below)\n\n-p     -prompt        <str>        Specify prompt explicitly\n\n-s     -speed         <num>        Simulated typing speed (seconds/char)\n\n-e     -echo          <str>        What to echo for each char typed\n\n-nl    -newline       <str>        When a newline is typed, echo <str> instead\n\n-d     -default       <str>        What to return if only <return> pressed\n\n\n-r     -require       <hashref>    Each value of each entry must 'smartmatch'\nthe input else corresponding key is printed\nas error message:\n- Subs must return true when passed input\n- Regexes must pattern match input\n- Strings must eq match input\n- Arrays are flattened & recursively matched\n- Hashes must return true for input as key\n\n-u     -until         <str|rgx>    Fail if input matches <str|regex>\n-failif\n\n-w     -while         <str|rgx>    Fail unless input matches <str|regex>\n-okayif\n\n-m     -menu          <list|hash>  Show the data specified as a menu\nand allow one to be selected. Enter\nan <ESC> to back up one level.\n\n-1     -onechar                   Return immediately after first char typed\n\n-x     -escape                     Pressing <ESC> returns \"\\e\" immediately\n\n-raw   -rawinput                  Return only the string that was input\n(turns off context-sensitive features)\n\n-c     -clear                      Clear screen before prompt\n-f     -clearfirst                Clear screen before first prompt only\n\n-a     -argv                       Load @ARGV from input if @ARGV empty\n\n-l     -line                       Don't autochomp\n\n-t     -tty                        Prompt to terminal no matter what\n\n-y     -yes                        Return true if [yY] entered, false otherwise\n-yn    -yesno                     Return true if [yY], false if [nN]\n-Y     -Yes                        Return true if 'Y' entered, false otherwise\n-YN    -YesNo                     Return true if 'Y', false if 'N'\n\n-num   -number                     Accept only valid numbers as input\n-i     -integer                    Accept only valid integers as input\n\nNote that the underscores between words in flags like \"-onechar\" and \"-yesno\" are optional.\n\nFlags can be \"cuddled\". For example:\n\nprompt(\"next: \", -tyn1s=>0.2)   # -tty, -yes, -no, -onechar, -speed=>0.2\n\n\"Hand-written\" printing via \"handprint()\"\nThe \"handprint()\" subroutine takes a string and prints it out in the stop-and-start manner of\nhand-typed text.\n\nLow-level input retrieval via \"getinput()\"\nThe \"getinput()\" subroutine is a low-level utility subroutine that takes an input filehandle,\nan output filehandle, a reference to a hash of options (as listed for \"prompt()\", above) and a\nsingle prompt string. It prints the prompt and retreives the input. You almost certainly want to\nuse \"prompt()\" instead.\n",
            "subsections": []
        },
        "DIAGNOSTICS": {
            "content": "\"Can't write prompt to read-only $\"\nYou specified a filehandle to which the prompt should be written, but that filehandle was\nnot writeable. Did you pass the wrong filehandle, or open it in the wrong mode?\n\n\"Missing argument for %s option\"\nThe flag you specified takes an argument, but you didn't provide that argument.\n\n\"Unknown flag ($s) in prompt\"\nThe flag you specified wasn't one of those that \"prompt()\" understands. Did you misspell it,\nperhaps?\n\n\"Argument to -require must be hash reference\"\nThe \"-require\" option takes a single argument that is a hash. You tried to pass it something\nelse. Try a hash instead.\n\n\"Cannot write to terminal: %s\"\n\"Cannot read from terminal: %s\"\n\"prompt()\" attempted to access the terminal but couldn't. This may mean your environment has\nno \"/dev/tty\" available, in which case there isn't much you can do with this module. Sorry.\n\n\"Can't open %s: %s\"\n\"prompt()\" tried to read input via *ARGV from a file specified on the command-line, but the\nfile couldn't be opened for the reason shown. This is usually either a permission problem, a\nnon-existent file, or a mistyped filepath.\n\n\"Argument to -menu must be hash or array reference\"\nThe \"-menu\" option requires an argument that is either an array:\n\nprompt -menu=>['yes', 'no', 'maybe'];\n\nor a hash:\n\nprompt -menu=>{yes=>1, no=>0, maybe=>0.5};\n\nor a hash of hashes (of hashes (of array))\n\n\"Too many -menu items\"\n\"Too few -menu items\"\nA menu can't have fewer than 1 or more than 26 items.\n",
            "subsections": []
        },
        "CONFIGURATION AND ENVIRONMENT": {
            "content": "IO::Prompt requires no configuration files or environment variables.\n",
            "subsections": []
        },
        "DEPENDENCIES": {
            "content": "IO::Prompt requires the following modules:\n\n*   version\n\n*   IO::Handle\n\n*   Term::ReadKey\n",
            "subsections": []
        },
        "INCOMPATIBILITIES": {
            "content": "The module requires a /dev/tty device be available. It is therefore incompatible with any system\nthat doesn't provide such a device.\n",
            "subsections": []
        },
        "BUGS AND LIMITATIONS": {
            "content": "No bugs have been reported.\n\nPlease report any bugs or feature requests to \"bug-io-prompt@rt.cpan.org\", or through the web\ninterface at <http://rt.cpan.org>.\n",
            "subsections": []
        },
        "FAQ": {
            "content": "This is a collection of things that might help. Please send your questions that are not answered\nhere to Damian Conway \"<DCONWAY@cpan.org>\"\n\nCan I use this module with ActivePerl on Windows?\nUp to now, the answer was 'No', but this has changed.\n\nYou still cannot use ActivePerl, but if you use the Cygwin environment\n(http://sources.redhat.com), which brings its own perl, and have the latest IO::Tty (v0.05 or\nlater) installed, it should work (feedback appreciated).\n",
            "subsections": []
        },
        "THANKS": {
            "content": "My deepest gratitude to Autrijus Tang and Brian Ingerson, who have taken care of this module for\nthe past twelve months, while I was off trekking in the highlands of Perl 6. Now it's their turn\nfor some mountain air, I'll be looking after this module again.\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "Damian Conway \"<DCONWAY@cpan.org>\"\n",
            "subsections": []
        },
        "LICENCE AND COPYRIGHT": {
            "content": "Copyright (c) 2005, Damian Conway \"<DCONWAY@cpan.org>\". All rights reserved.\n\nThis module is free software; you can redistribute it and/or modify it under the same terms as\nPerl itself.\n",
            "subsections": []
        },
        "DISCLAIMER OF WARRANTY": {
            "content": "BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE\nEXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT\nHOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE \"AS IS\" WITHOUT WARRANTY OF ANY KIND, EITHER\nEXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY\nAND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE\nSOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY\nSERVICING, REPAIR, OR CORRECTION.\n\nIN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER,\nOR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE\nLICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR\nCONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT\nLIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD\nPARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR\nOTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.\n",
            "subsections": []
        }
    },
    "summary": "IO::Prompt - Interactively prompt for user input",
    "flags": [],
    "examples": [],
    "see_also": []
}