in reply to Re^2: Max value
in thread Max value

A couple of changes would be required if you can have several maximum values (such as using an array of the indices with the max value and adding a test for equality), but this is left as an exercise to the reader.

Mind showing an example for that? I still don't understand how to do it.

Replies are listed 'Best First'.
Re^4: Max value
by Laurent_R (Canon) on Apr 17, 2019 at 09:18 UTC
    Perhaps something like this (still untested):
    my @max_i; my $max = $arrayh[0]; for my $i (0..$#arrayh) { if ($arrayh[$i] > $max) { $max = $arrayh[$i]; @max_i = ($i); } elsif ($arrayh[$i] == $max) { push @max_i, $i; } } print " Max values are: \n" print "- $wire[$_]\n" for @max_i;