Subject: | Possible Bug |
Date: | Tue, 27 May 2008 16:07:09 -0300 |
To: | <bug-IO-Prompt@rt.cpan.org> |
From: | "Rafael Barros" <Rafael.Barros@locaweb.com.br> |
Message body not shown because it is not plain text.
Hello,
I don't know if this
is really a bug, but I have installed IO::Prompt on a Fedora 8 machine, and
every call to prompt() with the -r option specified would trigger a
warning:
Use of uninitialized
value in pattern match (m//) at /usr/lib/perl5/site_perl/5.8.8/IO/Prompt.pm line
91.
the problem is shown
when I try to execute the following code:
prompt( "Some
message: ", -r => { "put something here>" => qr/\w+/
});
I looked into the
code to see what was happenning, and found out that the problem was in this
segment of code, in the file mentioned above:
@data = map { $flags_alias{$_} || $_ } @data;
for (my $i = 0 ; $i < @data ; $i++) {
local *_ = \($data[$i]);
if (ref eq 'HASH') {
splice @data, $i + 1, 0, %$_;
}
for (my $i = 0 ; $i < @data ; $i++) {
local *_ = \($data[$i]);
if (ref eq 'HASH') {
splice @data, $i + 1, 0, %$_;
}
the problem is that, when splice is called in -r, two arguments of @data are removed from the array. If this is the last argument, the array becomes empty and $_ gets the value undef in the next iteration. When the code does ref eq 'HASH' again, the warning is sent.
I think that only
changing the if clause to be defined $_ and ref eq 'HASH' would resolve the
problem.
Ah, my version of
IO::Prompt is 0.99.4. My Fedora has the kernel 2.6.24.7-92.fc8 and my perl is
5.8.8.
Thanks,
Rafael Adson Barbosa
Barros