in reply to Navigating in hash of hash

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'};