in reply to detecting errors when a sub returns undef
If you can't omit keys with undefined values, change your code to:
sub check_foo { if (exists $foo{bar} and $foo{bar}) return $foo{bar}; } else { return undef; } } [download]