in reply to How to restrict the user to enter only 1 character
Actually, I think it would be more intuitive to allow them to type 'y', 'n', 'yes', 'no', 'Yes', or 'No' and simply test the first character.
my $answer = <STDIN>; my $first_char = substr $answer, 0, 1; if ( lc $first_char eq 'y' ) { # they answered 'yes' } else { # they answered something else }
Cheers,
Ovid
Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: (Ovid) Re: How to restrict the user to enter only 1 character
by dmmiller2k (Chaplain) on Oct 30, 2001 at 03:05 UTC |