I am not sure if I understand it correctly, but you can't. I mean I think you want some kind of iterator to move (in a hash) from lesson to lesson in order but there is no such thing. You need to write it by yourself. As you iterate over all elements, store them in an array and then you can iterate over array to get what you need.

Update: Following structure comes to my mind:
$available_data{'02'}{'03'} = {unit => '02', lesson => '03', next => u +ndef}; $available_data{'02'}{'05'} = {unit => '02', lesson => '05', next => u +ndef}; $available_data{'02'}{'03'}{next} = $available_data{'02'}{'05'}; $available_data{'02'}{'11'} = {unit => '02', lesson => '11', next => u +ndef}; $available_data{'02'}{'05'}{next} = $available_data{'02'}{'11'}; etc...

Then next lesson's data for $unit and $lesson would be (untested)

$ref = $available_data{$unit}{$lesson}; print "Unit: $unit, lesson: $lesson -> Unit: ", $ref->{unit}, ' lesson +: ', $ref->{lesson};

Update2: but it would be soooo much easier to make it as array from the beginning:

my @available_data; push @available_data, {unit => '02', lesson => '03'}; push @available_data, {unit => '02', lesson => '05'}; push @available_data, {unit => '02', lesson => '11'}; push @available_data, {unit => '03', lesson => '02'};

In reply to Re: Navigating in hash of hash by grizzley
in thread Navigating in hash of hash by Dirk80

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.