I am relatively new to Perl and I do not want to use the List::Util max
function to find the maximum value of a given array.
When I test the code below, it just returns the first value of the array, not the maximum.
sub max
{
my @array = shift;
my $cur = $array[0];
foreach $i (@array)
{
if($i > $cur)
{
$cur = $i;
}
else
{
$cur = $cur;
}
}
return $cur;
}