in reply to getting the highest value in a simpler way

There are more ways to get the max of a array. You can calc to max value whenever you insert something, or use
use List::Util qw/max/; my $highestvalue = max @holdmutual; printf "%.3f", $highestvalue;
The other part of the question is that you might use sprintf or printf.
Boris

Replies are listed 'Best First'.
Re^2: getting the highest value in a simpler way
by replicant4 (Novice) on Nov 10, 2004 at 11:59 UTC
    Replicant4 What I am actually asking is that I don't really need to store all the values I just need the maximum. So is there a way that instead of using an array, I can just store mutual and every time that my program goes through the loop, if mutual is higher then it will be replaced. My actual problem is that for every round ~1500x1500 calculations are being processed and this takes up a very large amount of time. Thanks
      Here is another way:
      package XX::Maximum; sub new { my ( $class, $value ) = @_; bless \$value, $class } sub set { ${$_[0]} = $_[1] } sub get { ${$_[0]} } sub insert { return ${$_[0]} unless defined $_[1]; return ${$_[0]} = ( !defined(${$_[0]} ) ? $_[1] : ( ${$_[0]} > $_[1] + ? ${$_[0]} : $_[1] )); } package main; my $t = XX::Maximum->new; $t->insert(1); $t->insert(0); $t->insert(undef); print $$t, "\n"; $t->insert(-10); print $$t, "\n"; $t->insert(10); print $$t, "\n"; print $t->get, "\n"; $t->set(undef);
      Boris