Hi everyone.

I'm trying to create a hash (or rather a HoH I believe) and need some assistance.
%hash = ( 1 => { 1 => "", #dynamically created name => "", that => "", }, 2.... # iteration );
Above is what my hash structure looks like. It is dynamically built as I'll never know how deep or how many items there will be. The tricky part for me is the first "1" in the example above is an iterator. On particular iterations through my loop if it == that number, I need to look into that hash's data.

The second "1" is where I dynamically lable my items and the other attributes. My question is, how do I determine the greatest number that exists so I know what the next one has to be? Pretend we need to create another event under iterator count 1. I know how to check existance to see if it is defined, I just don't know the easiest way to see the highest count if I need to build more.
$hash{1}{1} = "blah"; $hash{1}{2} = "blah";
In the above, how could I detect {2} as the highest number so I know to start at {3} next time something is added?

In short, each iterator count could have more than one "event" and I need a way to record as many events as necessary. That way I only have to look up $hash{$num} to see all the events that take place for that iteration.

In reply to Determine largest key in hash by Anonymous Monk

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.