Is there a simple way to validate a hash of hash element exist and defined?
Posted
by WL
on Stack Overflow
See other posts from Stack Overflow
or by WL
Published on 2010-04-27T17:34:53Z
Indexed on
2010/04/27
18:33 UTC
Read the original article
Hit count: 179
I need to validate a Perl hash of hash element such as $Table{$key1}{$key2} exist and defined. Here is what i do. (i have no idea key1 even exist)
if
((defined $Table{$key1}) &&
(exists $Table{$key1}) &&
(defined $Table{$key1}{$key2}) &&
(exists $Table{$key1}{$key2}))
{
#do whatever
}
Is there an easier and cleaner way to do it?
© Stack Overflow or respective owner