Re: Use of uninitialized value in string eq



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.

I originally only check if the two strings were defined, but then I
read in perldiag that "An undefined value was used as if it were
already defined. It was interpreted as a "" or a 0, but maybe it was a
mistake. To suppress this warning assign a defined value to your
variables." So, to be safe, I verified that neither $exploit_name nor
'ALL' could be any kind of false value.

But still, this is my output:

$exploit_name is not any sort of false
String literal is not any sort of false
[*] WARNING: Use of uninitialized value in string eq at spinsploit.pl
line 507, <STDIN> line 2.

The '[*] WARNING: " bit comes from a module I'm using, which catches
SIG{__WARN__} and just prepends that string. I stepped through the
module's warning catcher with the debugger, and it was definitely sent
"Use of uninitialized value in string eq at spinsploit.pl line 507,
<STDIN> line 2." as a $_[0] value. I don't see how it could affect
the warning it was sent.

How is this possible? Any suggestions of other tests I could print
the output of or things to step through with the debugger?

- Jen

--
To unsubscribe, e-mail: beginners-unsubscribe@xxxxxxxx
For additional commands, e-mail: beginners-help@xxxxxxxx
http://learn.perl.org/



.



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. ...
    (perl.beginners)
  • RE: Offer a feature to disable the sort warning in Excel 2003
    ... And not just the sort warning for adjacent data found, ... > This is just a suggestion to MS. Feel free to add your opinion if you wish. ... > This post is a suggestion for Microsoft, ...
    (microsoft.public.excel.misc)
  • Re: OT - How to get away with murder
    ... Giving a warning to a suicide bomber isn't the smartest thing to do. ... some sort of detonation system which would explode if shot, a sort of, ... There was no "Stop Police" and quite frankly, with all the palavra, ...
    (uk.media.tv.misc)