in reply to Re^2: checking if hashref value exists based on a dynamic array
in thread checking if hashref value exists based on a dynamic array
But the problem with modules is that they do the work, and you don't know how they done it.
Probably something along the lines of the following, with error checking added.
my $p = \$href; $p = \($$p->{$_}) for @keys; $$p = $val;
Update: Oops, the above is code for setting with autovivification (your other question). Checking if the indexes exist without autovivification could be done using
my $p = $href; for (@keys) { return 0 if !exists($p->{$_}); $p = $p->{$_}; } return 1;
|
|---|