You just pass it your query and a regex and let it worry about doing the validation.use strict; use warnings; my $word = getInp('Enter a word : ', qr/^[a-z]+$/i); my $anything = getInp('Enter anything : '); sub getInp { print $_[0]; do { $_ = <STDIN>; chomp; } while ($_[1] && $_ !~ $_[1]); return $_; }
In reply to Re: Is there a module for handling interactive user inputs?
by TedPride
in thread Is there a module for handling interactive user inputs?
by johnnywang
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |