in reply to Finding the parent of a text in a file
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. $
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Finding the parent of a text in a file ( is_deeply )
by stevieb (Canon) on Sep 04, 2015 at 13:24 UTC | |
by 1nickt (Canon) on Sep 04, 2015 at 15:46 UTC | |
|
Re^2: Finding the parent of a text in a file ( is_deeply )
by ExperimentsWithPerl (Acolyte) on Sep 04, 2015 at 14:40 UTC | |
by 1nickt (Canon) on Sep 04, 2015 at 15:40 UTC | |
by ExperimentsWithPerl (Acolyte) on Sep 05, 2015 at 19:58 UTC |