Hi Maze,

I don't know which value is the unitialized one (mostly because you haven't shown any code besides the subroutine to give context), but I can give you a good clue as to how to find out.

Simply print out the variables for the line where the error is occurring.  If it's the last one, try something like:

printf "TFD> count is '%s'\n", $count; printf "TFD> path[count] is '%s'\n", $::path[$count]; printf "TFD> direntry[count] is '%s'\n", $::direntry[$count]; printf "TFD> FileLabel is '%s'\n", $::FileLabel; printf "TFD> DirLabel is '%s'\n", $::DirLabel;

For something like treeref which is more than a mere scalar value, you can use the module Data::Dumper, which is invaluable in these situations:

use Data::Dumper; printf "TFD> treeref => '%s'\n", Dumper(\$treeref);

That should tell you pretty quickly if you have an undefined value, and exactly which it is.

Update:  I should have mentioned that I use the string "TFD" to mean "Temporary - for debug".  It's an easy way to add debugging information that can later be searched for and removed.


s''(q.S:$/9=(T1';s;(..)(..);$..=substr+crypt($1,$2),2,3;eg;print$..$/

In reply to Re: uninitialised value in hash reference by liverpole
in thread uninitialised value in hash reference by Maze

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.