in reply to Useful uses of redo?
my %is_legal = map { $_ => 1 } qw( y yes n no ); my $answer; { print "What is your answer? "; chomp( $answer = <> ); $answer = lc $answer; last if $is_legal{ $answer }; redo; } # Do something with $answer, which is now guaranteed to be 'y', 'yes', + 'n', or 'no'
------
We are the carpenters and bricklayers of the Information Age.
Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose
I shouldn't have to say this, but any code, unless otherwise stated, is untested
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Useful uses of redo?
by belg4mit (Prior) on Aug 27, 2004 at 04:40 UTC |