Hi nysus, thank you very much for the response. Exactly what I was looking for!

New code is here.

#!/usr/bin/perl # Compare two schemas or tables for names, types and length. use v5.10; no strict; my %tables1_lookup=(); my %tables2_lookup=(); my %DS1=( PERL => [ {TABLES=>{ TABSCHEMA=>"VARCHAR(128)", TABNAME=>"VARCHAR(12 +8)", }}, # Tables and Columns are names of the tables. {COLUMNS=>{ TABSCHEMA=>"VARCHAR(128)", TABNAME=>"VARCHAR(1 +28)", COLNAME=>"VARCHAR(128)", PARTKEYSEQ=>"SMALLINT", }} ] ); my %DS2=( PERL => [ {TABLES=>{ TABSCHEMA=>"VARCHAR(256)", TABNAME=>"VARCHAR(12 +8)", }}, # Tables and Columns are names of the tables. {COLUMNS=>{ TABSCHEMA=>"VARCHAR(256)", TABNAME=>"VARCHAR(1 +28)", COLNAME=>"VARCHAR(128)", PARTKEYSEQ=>"SMALLINT", }} ] ); foreach my $schema1 (keys %DS1) { if (exists $DS2{$schema1}) { say "Schema $schema1 exist in target."; } else { die "Schema $schema1 does not exist in target."; } # Build look up hashes with tables list for schema one from DS1. foreach my $tabhash1_ref (@{$DS1{$schema1}}) { foreach my $tables1_name (keys %{$tabhash1_ref}) { $tables1_lookup{$tables1_name}=1; } } # Build look up hashes with tables list for schema two from DS2. foreach my $tabhash2_ref (@{$DS2{$schema1}}) { foreach my $tables2_name (keys %{$tabhash2_ref}) { $tables2_lookup{$tables2_name}=1; } } foreach my $tables1_name(keys %tables1_lookup) { if (! exists $tables2_lookup{$tables1_name}) { say "$tables1_name table does not exists in target schema 2. +" } else { say "$tables1_name table exists in target schema 2" } } }
Output is here:

Schema PERL exist in target. COLUMNS table exists in target schema 2 TABLES table exists in target schema 2
Looks like I need to learn how to use hashes as lookup tables :-)

In reply to Re^2: Comparing 2 arrays of hashes by raghuprasad241
in thread Comparing 2 arrays of hashes by raghuprasad241

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.