my $unit; my $lesson; my $next; # defaults to "undef" $available_data{'02'}{'03'} = undef; $available_data{'02'}{'05'} = undef; $available_data{'02'}{'11'} = undef; $available_data{'05'}{'02'} = undef; $available_data{'05'}{'03'} = undef; $available_data{'07'}{'01'} = undef; $available_data{'07'}{'04'} = undef; $available_data{'07'}{'07'} = undef; $available_data{'07'}{'08'} = undef; for $unit ( sort { $b cmp $a } keys %available_data ) { for $lesson ( sort { $b cmp $a } keys %{$available_data{$u +nit}} ) { $available_data{$unit}{$lesson}{'next'} = $next; $next = "$unit-$lesson"; } } # Unit 05, Lesson 03 --> Unit 07, Lesson 01 $unit = "05"; $lesson = "03"; print "Unit " . $unit . ", Lesson " . $lesson . " --> Unit " . substr($available_data{$unit}{$lesson}{'nex +t'}, 0, 2) . ", Lesson " . substr($available_data{$unit}{$lesson}{'next +'}, 3, 2) . "\n";
In reply to Re^2: Navigating in hash of hash
by Dirk80
in thread Navigating in hash of hash
by Dirk80
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |