Subject: | "uninitialized value" warning |
Date: | Tue, 30 Aug 2011 12:57:20 -0400 |
To: | bug-POE-Component-IRC [...] rt.cpan.org |
From: | "Daniel Macks" <dmacks [...] netspace.org> |
Running self-tests on POE-Component-IRC 6.70 on OS X 10.6 using perl 5.10.0 (part of the base system from Apple) I get a bunch of warnings:
S_353 call on self failed: Use of uninitialized value $status in length at /sw/build.build/poe-component-irc-pm5100-6.70-1/POE-Component-IRC-6.70/blib/lib/POE/Component/IRC/State.pm line 472.
The warning appears to indicate a logic flaw in that .pm:
my $status;
if ( ($status) = $nick =~ /^($search+)/ ) {
$nick =~ s/^($search+)//;
}
[...]
$status = '' if !length $status;
I assume the intent of that last line is to make sure $status is defined. That's the only case I can think of where a variable with zero length is *not* the null-string already). But that's exactly the case that triggers the warning too. Cleaner to test for that problematic case directly:
$status = '' if !defined $status;
dan
--
Daniel Macks
dmacks@netspace.org