TJRandall has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl -w use strict; use Data::Dumper; my %hash = ( TABLE_NAME => { COLUMN_NAME => { 'CYCLE_DATE' => { TYPE => 'VARCHAR2(20)', NULLABLE => 'N' +}, 'SOME_DATE' => { TYPE => 'DATE', NULLABLE => 'N' +}, 'AMITRUE' => { TYPE => 'BOOLEAN', NULLABLE => 'N' +} } } ); my %hash2 = ( TABLE_NAME => { COLUMN_NAME => { 'CYCLE_DATE' => { TYPE => 'VARCHAR2(20)', NULLABLE => 'Y' +}, 'SOME_DATE' => { TYPE => 'SOMEGUY', NULLABLE => 'N' +}, 'AMITRUE' => { TYPE => 'BOOLEAN', NULLABLE => 'N' +}, 'THE_DUDE' => { TYPE => 'VARCHAR2(10)', NULLABLE => 'Y' +} } } ); # works for walking single hash - have just started # trying to figure out how I'd do both. walk_hash(\%hash, \%hash2); sub walk_hash { my ($h1, $h2) = shift; foreach my $key (keys %$h) { if( ref $h->{$key}) { walk_hash( $h->{$key} ); } else { print $h->{$key}; } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Comparing two deep hash of hashes
by Tux (Canon) on Sep 16, 2011 at 13:23 UTC | |
|
Re: Comparing two deep hash of hashes
by muba (Priest) on Sep 16, 2011 at 13:30 UTC | |
by Anonymous Monk on Oct 14, 2014 at 11:58 UTC | |
|
Re: Comparing two deep hash of hashes
by raybies (Chaplain) on Sep 16, 2011 at 13:32 UTC | |
by TJRandall (Sexton) on Sep 16, 2011 at 13:44 UTC |