use warnings; use strict; use Data::Compare; my $part = { 'c' => {}, 'func' => [] }; my $main = { 'a' => { 'b' => { 'c' => {}, 'func' => [] }, 'func' => [ 'd', 'e' ] } }; for my $inner (keys %$main){ for my $key (keys %{ $main->{$inner} }){ my $its_here = Compare $part, $main->{$inner}{$key}; if ($its_here){ print "found at location $key\n"; } } }