Is it possible to iterate/loop/traverse over two hashes at one go? e.g I have

%hash1 = (..... (key value pair) .... ....); %hash2 = (.... ..... .....); while(......) #iterate both hashes at once { #process something..... }
How should i go about it?

Thank you all for the answers... all above for the answering. I am trying something on bigram techniques. where i have stored bigram count in one hash and word count in other.

What i am trying to do is: From looping those hashes at once, I want to take the value of bigram count and divide with the value of word count.

In case of ordering i used Tie::IxHash module from CPAN. Any better solution to the way i approached my work will be appreciated... Thanks.


In reply to iterate/traverse Two Hashes at once by cthar

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.