my $HoA_ref = {'GAT' => [2, ['ttt',-3,1],['ttc',-3,3],['ccc',-1,2]], 'AAA' => [13,['aaa',-1,2],['atg',-2,2]], 'TTT' => [11,['tta',-2,1],['atc',-3,3]] }; # Find key associated with highest value my ($key, $max); for(keys(%{$HoA_ref})) { if( $HoA_ref->{$_}[0] > $max ) { $key = $_; $max = $HoA_ref->{$_}[0]; } } # output the item with the max value print "$key $max:\n"; my @out = @{ $HoA_ref->{$key} }; # skip zeroth element for(1..$#out) { print join ',', @{ $out[$_] }, "\n"; }