Hi guys-
I'm trying to test whether nested hash refrences exist, like so:
Can anyone help me out here? The main thing is that it doesn't auto-create the keys if they don't exist. I need to make sure it's not auto-vivifying the data. In order to do this I was told I need to use recursion, which is great because I really want to understand how recursion works... I get the concept, but then to apply it in practice is so hard for me. Thanks
~Eric
I'm trying to test whether nested hash refrences exist, like so:
Code:
my %ref = (
'app' => {
'next' => {
'further' => 10
}
}
);
if (nested_exists(\%ref, 'app', 'next', 'further')) {
do whatever.....
}
sub nested_exists {
my ($ref, @keys) = @_;
.....i just don't get it :(
}
Can anyone help me out here? The main thing is that it doesn't auto-create the keys if they don't exist. I need to make sure it's not auto-vivifying the data. In order to do this I was told I need to use recursion, which is great because I really want to understand how recursion works... I get the concept, but then to apply it in practice is so hard for me. Thanks
~Eric