Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Tracking down "uninitialized value" errs

by jest (Pilgrim)
on Jul 30, 2003 at 08:01 UTC ( #279112=perlquestion: print w/ replies, xml ) Need Help??
jest has asked for the wisdom of the Perl Monks concerning the following question:

O monks,

I have a program that's throwing a large number of "Uninitialized value" errors. I've been very careful to always assign values like '' or whatever as defaults, wherever there's the opportunity to do so, but still they come.

The program in question involves a number of modules, so it's not that easy to figure out where things are happening, and the error in this case is the unhelpful "Uninitialized value in join or string at (eval 54) line 16". Is there any way to figure out exactly where this is? I don't have any eval's of my own.

I've looked over the archives but this particular question doesn't seem to have been covered. Thank you for any suggestions.

Comment on Tracking down "uninitialized value" errs
Download Code
Re: Tracking down "uninitialized value" errs
by Abigail-II (Bishop) on Jul 30, 2003 at 09:00 UTC
    You could use a WARN handler. Something like:
    $SIG {__WARN__} = sub { require "Carp.pm"; Carp::cluck @_; }

    This will give you a stack trace of from where the warning occurred.

    Abigail

      Thank you so much! This led me right to the problem, if rather verbosely.

      It turns out that whilst streamlining my code, I made incorrect use of a hash slice that brought in more values--some of which were undef--than I had intended; these had no effect on the display but generated errors.

Re: Tracking down "uninitialized value" errs
by nite_man (Deacon) on Jul 30, 2003 at 09:21 UTC
      Could you elaborate on your suggestion? From reading the documentation of the Error module, and the article you pointed to, it isn't clear to me at all how the Error module could help in catching warnings from already written code.

      From what I understood is that the Error module provides you a frame work to set up your own exception handling mechanism, where you can throw exceptions and catch them. Which is something completely different from what the OP wants to do.

      Abigail

        Generally, you are right, but, in my mind, this problem was because there were not defined some values in the programm. So, using catch of exeptions can help to know, where undefined data were used and corrected them.

        _ _ _ _ _ _
          M i c h a e l

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://279112]
Approved by arthas
Front-paged by broquaint
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (12)
As of 2014-10-31 13:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (217 votes), past polls