in reply to compare two reference in perlway
I'm with Eily. Data::Compare does this work very well. Here's an example:
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"; } } }
|
|---|