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