in reply to Tracking down uninitialized values...

There is no easy way to really fix those warnings. But let me encourage you to do it anyway. Each one should have the offending module and line number already on it. Go there. It usually doesn't take much time to fix each one by either giving the variable a defined value or adding a test for definedness if undefs are proper values.

Sorry I can't offer a quick fix for old messes.

Phil

  • Comment on Re: Tracking down uninitialized values...

Replies are listed 'Best First'.
Re^2: Tracking down uninitialized values...
by Slipstream (Monk) on Jul 28, 2006 at 16:11 UTC
    You're right. On many that I've been fixing I was able to use the line number to fix it, however, this one has me stumped so I intentionally left out the additional info it gives in hopes of finding general answers for how to track them down vs. this specific instance. Though since I've mentioned it now, here's the full message: "Use of uninitialized value in join or string at (eval 39) line 15."

    Thanks for the quick response!

      You have to figure out what the 39th call to eval is, and look at line 15 in it:

      use warnings; foreach my $i ( 1..5, undef, 7..9 ) { eval '$x = join("",$i,"");'; } # Use of uninitialized value in join or string at (eval 6) line 1.
      If you don't have a good line number, start putting warn statements in the code. Their output will go to standard err just like the uninitialized value warnings, so they will appear in sequence with the problem. By knowing which warns come before and after the one you are tracking, you can locate it.

      Phil

      Update: corrected to show warn goes to stderr, thanks Hue-Bond.