You can write a function as:
use strict; use warnings;
print max(@ARGV);
sub max {
my $max = shift;
$max >= $_ or $max = $_ for @_;
return $max;
}
However, it would be much more efficient to pass it an array reference and use it even more efficiently List::Util::max.
source
share