Subject: | when tries == 0, user is only given one attempt to choose a menu option |
The documentation for Term::Menu states that when the configuration
option "tries" is set to 0, which is the default, that menus generated
with Term::Menu will allow the user an unlimited number of attempts to
choose a valid value. However, when "tries" is 0, the user is only
given one chance before they're notified they've tried too many times.
The code just increments a variable, $tried, every time the user fails
to choose a valid value, and checks if $tried >= $tries when deciding
whether or not to continue or notify the user. The included patch,
generated from mercurial, makes sure $tries != 0 before notifying and
stopping.
Distribution: Net-Term-0.09
Perl Version: Strawberry Perl, specifically: "perl, v5.10.0 built for
MSWin32-x86-multi-thread"
Operating System: Windows XP SP2, 32-bit
Subject: | TermMenu.patch |
# HG changeset patch
# User Jeffrey D Johnson <jeffreyd@gmail.com>
# Date 1267194002 18000
# Node ID 7ea5270f55a77661942675b77c2fbe3f6a7bf9fe
# Parent 620de470a848e002549e117b1ae2ba021cfa5932
Fixed such that tries => 0 means unlimited tries.
diff -r 620de470a848 -r 7ea5270f55a7 lib/Term/Menu.pm
--- a/lib/Term/Menu.pm Fri Feb 26 09:12:37 2010 -0500
+++ b/lib/Term/Menu.pm Fri Feb 26 09:20:02 2010 -0500
@@ -86,12 +86,12 @@
# The line below was a hint by Stephen Davies, thanks!
$self->{tried} = 0 if(!defined($self->{tried}));
$self->{tried}++ if($self->{tries});
- if($self->{tried} >= $self->{tries}) {
+ if($self->{tried} >= $self->{tries} and $self->{tries} != 0) {
last;
}
}
}
- if(defined($self) and ${$self}{tried} >= ${$self}{tries}) {
+ if(defined($self) and ${$self}{tried} >= ${$self}{tries} and ${$self}{tries} != 0) {
print ${$self}{toomanytries},"\n" if defined ${$self}{toomanytries};
${$self}{tried} = 0;
${$self}{lastval} = undef;