Here's a rough idea:
use strict;
use warnings;
my $deep_hash = {
aa => {
bb => { cc => 111, dd => 222 },
ee => 333,
},
ff => 444,
};
sub dive {
my $h = shift;
for my $k (@_){
return unless (ref($h) eq 'HASH' and exists $h->{$k});
$h = $h->{$k};
}
return $h;
}
dive($deep_hash, qw(aa bb dd));