I have a %hash that when printed with DUMPER gives something like :
'555549' => [ '172193', '19601', '19602', '3252', '3665', '8959', '4758', '14835', '16718' ], '560834' => [ '172193', '19601', '19602', '3252', '3665', '8959', '4758', '14835', '16718' ],

There are more though. So i will like to be able to read the first 2 key values in the hash, compare them(this i know how to) then insert the difference somewhere(i know how). Then take the 3rd key(present) and compare with the 2nd one(previous).Do the same until the whole keys have been iterated through. So its just pick previous and present,do my thing, move to next etc. The truth is, i don't know how to access each key the way i explained in style of previous/present. Any algorithms,tips,answers will be useful.</code>

This is how i populated the %hash:

my %result; while ( my $rec = $data->fetchrow_hashref ) { push @{ $result{ $rec->{"ID"} } }, $rec->{"item"}; }

In reply to compare previous and present hash key values by undisputed

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.