The code would be easier to read ( and thus easier to comment on and make more efficent ) if you changed a couple things, first try using a little more descriptive names than i,j,k,m,n and o. Also as it doesn't appear that you modify the value of i/j or k/m within the context of one loop just get rid of j and m refer to them instead as (i+5) and (m+5). I think also changing for $R (0..$#ranges) to foreach $range (i,i+5,m,m+5) it wont make your code run any faster, as others have noted above, reading in a 22MB file into an array, and itterating through that array that many times just isn't a good thing, but it's a good place to start.


daN.

In reply to Re: inefficient code? works on small files ok but not larger ones by mutated
in thread inefficient code? works on small files ok but not larger ones by Anonymous Monk

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.