my $max = pop @{[sort @vals]}; #### use List::Util qw(max); my $max = max @vals;