my $max; for (@list) { $max = $_ if ! defined $max || $_ > $max; } #### use List::Util 'max'; print max(@list), "\n";