Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

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.

Replies are listed 'Best First'.
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::cluck @_; }

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


      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.


        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?

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2022-01-24 11:51 GMT
Find Nodes?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:

    Results (64 votes). Check out past polls.