for (keys %$hashref) { $query = $_; $hashref->{$query}->[$idxMax] > $hashref->{$query}->[$_] or $idxMax = $_ for 1 .. @$#hashref->{$query}; #finds the index of the biggest array element print "Hello World\n"; }