odrevet has asked for the wisdom of the Perl Monks concerning the following question:
It's a simple question. I've got a function that return a hash or undef if no value is found.
my %resp = my_func(); if(defined %resp) { #do something like print $resp{foo}; print{bar}; }
If the function return undef, I've got the warning "Odd number of elements in hash assignment".
That's makes sense, since the hash got only one value (undef). But I need to check if the hash has values, or the application will crash if I just assum there are values and try to use it...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: return a hash or undef
by moritz (Cardinal) on Aug 03, 2009 at 20:05 UTC | |
|
Re: return a hash or undef
by hobbs (Monk) on Aug 03, 2009 at 20:25 UTC | |
|
Re: return a hash or undef
by psini (Deacon) on Aug 03, 2009 at 19:59 UTC | |
|
Re: return a hash or undef
by jethro (Monsignor) on Aug 03, 2009 at 20:14 UTC | |
|
Re: return a hash or undef
by halfcountplus (Hermit) on Aug 03, 2009 at 20:14 UTC |