#!/usr/bin/perl use strict; use warnings; my %hash=(1=>10,2=>20,3=>30,4=>40,5=>50); my $max=0; my @out=map{ $_=$hash{$_}; if($_>$max){$max=$_} else { ()} # $_; }keys %hash; print "Max value was $max\n"; use Data::Dumper; print Dumper \@out; # prints Max value was 50 $VAR1 = [ 40, 50 ];