Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
While writing this I started to think that this might just be a matter of preference so just in case I'll rephrase the question to what are some examples of better ways to go about doing this task.print "Delete this file?[n]: "; chomp(my $answer=<STDIN>); if ($answer=~/^y|yes$/i){ unlink $file or die $!; } elsif ($answer=~/^n|no|$/i){ next; } else { .....
I'm trying to get away from using /^y|yes$/i and making everything else no or nprompt? accept: y,n,yes,no default: to one of the above continue with program flow
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: prompting a user for input
by Anarion (Hermit) on Nov 04, 2001 at 15:11 UTC | |
|
Re: prompting a user for input
by joealba (Hermit) on Nov 04, 2001 at 18:00 UTC | |
|
Re: prompting a user for input
by perigeeV (Hermit) on Nov 04, 2001 at 17:50 UTC | |
|
Re: prompting a user for input
by staeryatz (Monk) on Nov 04, 2001 at 23:42 UTC | |
by blakem (Monsignor) on Nov 05, 2001 at 02:14 UTC | |
by s0ttle (Scribe) on Nov 11, 2001 at 20:21 UTC |