Thanks CountZero.
My code was actually just a smaller part of the whole that I was using to isolate the problem I was experiencing. I wasn't having a problem with processing the response from the user, though.
I like your solution, but it's a little hard to read and it doesn't work for my "neVer" answer.
At the risk of being less perlish, I'm using a less concise version that will be a little easier (for me) to read and understand when I look at the code again in the future:
if ($removeall == 1) {
unlink $origin;
} elsif ($removeall == 0) {
print "Remove '$origin'? ([Y]es, [N]o, [A]ll, ne[V]er; default: N)
+ ";
chomp(my $answer = lc(<STDIN>));
print "answer: |$answer|\n" if (DEBUG);
if (($answer eq 'y') or ($answer eq 'yes')) {
unlink $origin;
}
if (($answer eq 'a') or ($answer eq 'all')) {
unlink $origin;
$removeall = 1;
}
if ($answer eq ('v' or 'never')) {
$removeall = -1;
}
}
|