You can use is_deeply if you put your data into hashes. I'm making some assumptions here because your post isn't complete (eg that 'entry 1' and 'snmp ok' are keys, not key-value pairs) ... but hopefully this helps.
Output:#!/usr/bin/perl use strict; use warnings; use Test::More tests => 1; my ($href1, $href2) = get_data(); is_deeply( $href2, $href1, 'Hashref comparison' ); ## Sub to fetch data below; add code to read files if needed sub get_data { my $href1 = { system => { security => { management_ip => { protocol => { internal => {}, shutdown => {}, allow => {}, entry_1 => { snmp_ok => 'foo', }, exit => {}, }, }, }, }, }; my $href2 = { system => { security => { management_ip => { protocol => { internal => {}, shutdown => {}, allow => {}, entry_1 => { snmp_ok => 'bar', }, exit => {}, }, }, }, }, }; return $href1, $href2; } __END__
$ perl 1140982.pl 1..1 not ok 1 - Hashref comparison # Failed test 'Hashref comparison' # at 1140982.pl line 8. # Structures begin differing at: # $got->{system}{security}{management_ip}{protocol}{entry_1}{ +snmp_ok} = 'bar' # $expected->{system}{security}{management_ip}{protocol}{entry_1}{ +snmp_ok} = 'foo' # Looks like you failed 1 test of 1. $
In reply to Re: Finding the parent of a text in a file ( is_deeply )
by 1nickt
in thread Finding the parent of a text in a file
by ExperimentsWithPerl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |