Are you aware of the following problems in your updated code?

Name "main::r1" used only once: possible typo at mytest.pl line 23. Name "main::rL3" used only once: possible typo at mytest.pl line 59. Name "main::OR1" used only once: possible typo at mytest.pl line 63.

These are the offending lines:

$r1 = $c; # $r1 Used only once. # .... $lambda_next = ($lambda_max + ($ks * $rL3)) * (1 - $kdeg); # $rL3 used + only once. # .... $cro_next = ($cro_max + ($ks * $OR1)) * (1 - $kdeg); # $OR1 used only +once.

The second and third cases are most alarming, since you're using $rL3 and $OR1 in computations while they (apparently) have undef as their values.

Update: As for efficiency, you could completely eliminate the inner loop, since the condition $cro < $cro_max will never be true, as you set $cro_max to zero at the top of your script. ...I suppose that won't do much for computational efficiency; a loop that never runs steals very few cycles. But it will save a few keystrokes.


Dave


In reply to Re: making code efficient by davido
in thread making code efficient by doozy

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.