Re: Use of uninitialized value in string eq
- From: "DJ Stunks" <DJStunks@xxxxxxxxx>
- Date: 26 Jan 2007 11:34:05 -0800
On Jan 26, 11:37 am, a.r.ferre...@xxxxxxxxx (Adriano Ferreira) wrote:
On 1/26/07, Jen Spinney <jen.spin...@xxxxxxxxx> wrote:
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
In some circumstances, the line of the warning may be wrong. So the
problem can be around line 507 instead of exactly there.
This is true. The warning is thrown against the first line of the if.
If you have elsifs which trigger the warning, the line will be 505. I
probably didn't explain that very well so please have a look at this
example:
C:\tmp>cat -n tmp3.pl
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5
6 my $undefined;
7 my $defined = 'something';
8
9 if ( $defined eq 'defined' ) {
10 print "\$defined was defined\n";
11 }
12 elsif ( $undefined eq 'defined' ) {
13 print "\$undefined was defined\n";
14 }
15
16 __END__
C:\tmp>tmp3.pl
Use of uninitialized value in string eq at C:\tmp\tmp3.pl line 9
The warning actually occurs on line 12, but it's thrown against 9
because that's where the if block starts.
HTH,
-jp
.
- 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: writing a file in IIS
- Next by Date: port blocking on a wintel box
- 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
|