#namely how can I pick only the topmost with this subroutine #besides some reference error that I encounter. sub print_zHoA { my ($HoA) = @_; foreach my $mc (sort {$HoA{$a}[0] <=> $HoA{$b}[0]} keys %$HoA){ print "$mc $HoA{$mc}[0]:\n"; foreach my $i (0.. $#{$$HoA{$mc}}) { print "$$HoA{$mc}[$i]->[0],$$HoA{$mc}[$i]->[1],$$HoA{$mc}[$i]->[2]"; } print "\n"; } }