Skip Menu |

This queue is for tickets about the Term-UI CPAN distribution.

Report information
The Basics
Id: 13412
Status: resolved
Priority: 0/
Queue: Term-UI

People
Owner: Nobody in particular
Requestors: jorgen [...] devsoft.no
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.05
Fixed in: (no value)



Subject: get_reply: "default" isn't really optional
According to the docs (for get_reply) default The default answer -- This is the answer picked if the user just hits "enter" or if $AUTOREPLY is set to true. This parameter is optional. This really isn't optional. There's basically two problems: Pressing enter with no input, without default. Pressing enter with no input, where the allow-handler returns 0. In the former case, it'll warn on uninitalized values when adding it to the terminal history. In the latter case, it'll pass an undefined value to check() in Params::Check, as well as warn on the former. :) Should be easy enough to fix (atleast the former case, that I can do myself), good job on the module, though! It's quite handy! :) Example code: my $result; # Press enter without any input: $result= $term->get_reply(prompt => 'Test!'); Use of uninitialized value in length at /usr/local/share/perl/5.8.7/Term/UI.pm line 141. # Press enter without any input; no warning. $result = $term->get_reply(prompt => 'Test!', default => 'Foo'); # Press enter without any input: $result = $term->get_reply(prompt => 'Test!', allow => sub { 0; }); Use of uninitialized value in length at /usr/local/share/perl/5.8.7/Term/UI.pm line 141. Use of uninitialized value in string at /usr/local/share/perl/5.8.7/Params/Check.pm line 342. Kindest regards, Jørgen.
[guest - Sat Jun 25 15:14:30 2005]: Show quoted text
> According to the docs (for get_reply) > default > The default answer -- This is the answer picked if the user > just hits "enter" or if $AUTOREPLY is set to true. This parameter > is optional. > > This really isn't optional. There's basically two problems: > Pressing enter with no input, without default. > Pressing enter with no input, where the allow-handler returns 0. > > In the former case, it'll warn on uninitalized values when adding it > to the terminal history.
I've added a test case for this and fixed the bug ( a small defined check did the trick). Submitted @12093. Show quoted text
> In the latter case, it'll pass an undefined value to check() in > Params::Check, as well as warn on the former. :)
[...] Show quoted text
> # Press enter without any input: > $result = $term->get_reply(prompt => 'Test!', allow => sub { 0; }); > Use of uninitialized value in length at > /usr/local/share/perl/5.8.7/Term/UI.pm line 141. > Use of uninitialized value in string at > /usr/local/share/perl/5.8.7/Params/Check.pm line 342.
Looks like you might be using an older version of Params::Check -- latest version doesn't produce this warning for me, but i've added a test case nonetheless. I'll be releasing a reworked version of Term::UI shortly, based on this report. Thanks for catching it.