Mighty perl monks, my question might sound amateurt but I have a perls script that runs through a loop 500 times and each time I calculate a value called mutual. From each loop I need the highest value, so I have a few lines of code that do just that . My code is
push (@holdmutual,$mutual); print "vaggos3\n"; } #print " $l,$j,$mutual\n"; } #end of loop2 for each site2 #print " $l,$j,$mutual\n"; } #getting always the highest mutual inforamtion value for each si +te combination. my $highestvalue=0; foreach my $holdmutual(@holdmutual){ if ($holdmutual>$highestvalue){ $highestvalue=$holdmutual; }print "vaggos4\n"; } print "$highestvalue\n";
Does anyone has a suggestion of a simpler code that does that but it is not as memory intensive as mine? (for example I don't think that I need the array but I am not sure how to get rid of it.) Another thing is that the values I get have a lot of decimals. Is there any way for me to get only the first three decimal values e.g 1.678 instead of what I actually get 1.2345678977885454? Thanks in advance for anyone's help replicant4

In reply to getting the highest value in a simpler way by replicant4

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.