Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Why? uninitialized value in pattern match when using if (defined)

by kwaping (Priest)
on Mar 22, 2006 at 00:24 UTC ( [id://538359] : note . print w/replies, xml ) Need Help??


in reply to Why? uninitialized value in pattern match when using if (defined)

The hash key, $tmpf, is defined as "farms". However, the hash value $factories{$tmpf}, aka $factories{'farms'}, appears to be undefined.

---
It's all fine and dandy until someone has to look at the code.

Replies are listed 'Best First'.
Re^2: Why? uninitialized value in pattern match when using if (defined)
by pKai (Priest) on Mar 22, 2006 at 21:29 UTC

    Maybe so. Though we don't now by now, what the warning actually refers to.

    The OP is not very clear about this, but the consensus in the replies seems to be that the offending operation takes place inside a block guarded with:

    if ($factories{$tmpf})

    If $factories{$tmpf} had been undef, perl would not have reached the inside of that conditional block.

    Of course this is also pure guesswork, unless the OP succeds in posting some code to reproduce the problem. :-D

      Thank you for the reply, you make a good point that I didn't consider.

      ---
      It's all fine and dandy until someone has to look at the code.
        (Sorry for the delay in responding -- I thought I had written a reply, but apparently I haven't figured out the interface software, entirely, yet). Anyway, I've decided to rewrite the offending code. It appears as if the actual problem was something inside the block guarded by if ( defined $factories{ $tmpf}) -- cleaning that error up removed the warning. I'll try to post a more complete code snippet next time - I had intended to clean it up so it would be least confusing, and clearly went too far. Thanks to all who replied. I was rather surprised at the quantity (and helpfulness) of the responses.