Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: undefined hash elements

by MrTEE (Novice)
on Dec 18, 2013 at 20:57 UTC ( [id://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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (5)
As of 2024-03-28 21:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found