No, I think that s/he means that s/he wants to compare each of the values in the arrays pointed to (via array refs) by the corresponding keys in each hash. What I can't tell is if s/he expects the items to be in the same order in each hash or not.

If so, the most straight-forward way to do it would be something like:

my @Non_Matching_Keys; foreach $key (keys %HoL_compare_pub) { my @orig_a = @{$HoL_pub{$key)}; my @comp_a = @{%HoL_compare_pub{$key}}; foreach(0 .. @orig_a) { if($orig_a[$_] ne $comp_a[$_]) { push @Non_Matching_Keys, $key; } } }

Note that that is totaly untested. Also, if the order of the two arrays are different, it won't work. Maybe running a sort() on them both first would work?

Update: Nevermind... I think I got confused by the "Hash of Arrays" part (and I was in a hurry to leave work ;-)... Looks like Tuna just wanted to see if a router (hash element) existed in one hash and not the other, just like dfog and dkubb said. =)

bbfu
Seasons don't fear The Reaper.
Nor do the wind, the sun, and the rain.
We can be like they are.


In reply to (bbfu) (hash elements are array refs)Re: Re: Comaring contents of 2 Hash of Arrays by bbfu
in thread Comaring contents of 2 Hash of Arrays by Tuna

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.