Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

Re: undefined hash elements

by MrTEE (Novice)
on Dec 18, 2013 at 20:57 UTC ( #1067707=note: print w/replies, xml ) Need Help??

in reply to undefined hash elements

Is there a way to assing a value to the hash elements before they get assigned an elements so they are not 'undef'. I tried an if (!defined) thing but it was thowing errors.

Replies are listed 'Best First'.
Re^2: undefined hash elements
by jethro (Monsignor) on Dec 18, 2013 at 21:54 UTC

    defined() works. You might like to show us the code and error and we can fix that.

    If you want to check if a hash key exists at all, the function exists() is the right one to use

Re^2: undefined hash elements
by GrandFather (Saint) on Dec 19, 2013 at 00:41 UTC

    Don't do that. Almost always undef warnings point to a logic error. If you mask the warning you are ignoring the logic error. Better to figure out how you get into the state where the warnings are generated then fix the root cause than to paper over the cracks until the whole thing falls down around your ears.

    True laziness is hard work

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1067707]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (5)
As of 2022-06-28 14:40 GMT
Find Nodes?
    Voting Booth?
    My most frequent journeys are powered by:

    Results (92 votes). Check out past polls.