[wellylug] Getting user input into a Perl program
michael at diaspora.gen.nz
michael at diaspora.gen.nz
Sat Jan 28 23:37:30 NZDT 2006
Cliff Pratt writes:
>eg, what sort of stuff do I put in the sub 'ask_for_input'? In the case
>below, it would presumbly do something like ask "Continue (Y/N)?" and
>parse the response and return a true value if it gets a negative
>response and would break out of the loop.
use IO::Prompt;
STUFF: while (1) {
do_stuff();
last STUFF if prompt "Do more stuff [yn]? " -yesno;
do_more_stuff();
}
The IO::Prompt module from Damian Conway et al. is useful in these cases.
-- michael.
More information about the wellylug
mailing list