use List::Util qw( reduce ); my $highest_rated = reduce { $a->{Rating} >= $b->{Rating} ? $a : $b } grep $_->{Season} == $seasonnum, values %$hdata; my $banner_path = $highest_rated->{BannerPath};