in reply to return a hash or undef

If the function return undef, I've got the warning "Odd number of elements in hash assignment".
Yeah, that is kind of irritating isn't it? Probably there is a good reason.

You might want to investigate the use of eval...but also notice that this is allowed, even if %hash is "undef":
if (defined($hash{non-existant key})) ...
the condition, of course, will be untrue, unless there really is a key called "non-existant key" and it is defined.