Re: Use of uninitialized value in string eq
- From: jen.spinney@xxxxxxxxx (Jen Spinney)
- Date: Fri, 26 Jan 2007 14:04:10 -0500
On 1/26/07, Adriano Ferreira <a.r.ferreira@xxxxxxxxx> wrote:
On 1/26/07, Jen Spinney <jen.spinney@xxxxxxxxx> wrote:
> Hello list!
>
> I apologize in advance for not posting a complete sample script that
> shows my problem, but I can't isolate it outside of my (rather large)
> perl application.
>
> My problem is that I'm hit with a barrage of warnings that tell me I'm
> using uninitialized values. The first warning that occurs complains
> of a "use of uninitialized value in string eq" at line 505 of my
> script. Line 505 (I've triple-checked the line number and the correct
> source) reads:
>
> if ($exploit_name eq 'ALL') # <-- line 505
>
> I had no idea how $exploit_name could be undefined, so I added the
> following two statements right before the if statement:
>
> print "\$exploit_name is not any sort of false\n" if $exploit_name;
> print "String literal is not any sort of false\n" if 'ALL';
> if ($exploit_name eq 'ALL') # <-- now line 507
To see what you really got at $exploit_name, use Data::Dumper,
Data::Dump or any of your favourite dumpers:
use Data::Dump qw(dump);
print "\$exploit_name =", dump($exploit_name), "\n";
In some circumstances, the line of the warning may be wrong. So the
problem can be around line 507 instead of exactly there.
$exploit_name isn't a reference, but a string scalar.
Right before the if statement, I added these lines:
print "\$exploit_name = $exploit_name\n";
print "\$exploit_name = ", Dumper($exploit_name), "\n";
This outputs:
$exploit_name = icecast_header
$exploit_name = $VAR1 = 'icecast_header'
Followed by the same warning.
Maybe it is on another line. Weird. I'll peruse around my code a bit more...
Thanks for the quick response, Adriano!
- Jen
.
- References:
- Use of uninitialized value in string eq
- From: Jen Spinney
- Re: Use of uninitialized value in string eq
- From: Adriano Ferreira
- Use of uninitialized value in string eq
- Prev by Date: Re: Use of uninitialized value in string eq
- Next by Date: writing a file in IIS
- Previous by thread: Re: Use of uninitialized value in string eq
- Next by thread: Re: Use of uninitialized value in string eq
- Index(es):
Relevant Pages
|