Re: Use of uninitialized value in string eq



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
.



Relevant Pages

  • Re: Use of uninitialized value in string eq
    ... > I apologize in advance for not posting a complete sample script that ... > of a "use of uninitialized value in string eq" at line 505 of my ... To suppress this warning assign a defined value to your ... > module's warning catcher with the debugger, ...
    (perl.beginners)
  • Use of uninitialized value in string eq
    ... I apologize in advance for not posting a complete sample script that ... of a "use of uninitialized value in string eq" at line 505 of my ... To suppress this warning assign a defined value to your ... $exploit_name is not any sort of false ...
    (perl.beginners)
  • Re: Use of uninitialized value in string eq
    ... I apologize in advance for not posting a complete sample script that ... the line of the warning may be wrong. ... $exploit_name is not any sort of false ... module's warning catcher with the debugger, ...
    (perl.beginners)
  • RE: Service Unavailable
    ... Thanks for your posting. ... this issue is more likely related to IIS. ... I used to run an ASP application on a windows 2000 server and everything ... Warning: 1009 ...
    (microsoft.public.windows.server.migration)
  • Re: [opensuse] Preferred PDF Reader
    ... It is pointless to post email that is only warning about posting ... New openSUSE email user will feel unwanted and go away. ... Old list user does that intentionally and warning has no effect. ... Swift Change for a Green Future: ...
    (SuSE)