Your ISP counts IO processes??? How about RAM usage? And what the heck is an "IO process"? And how can your ISP tell?

Generally speaking, reading a record, working with it, saving it, and moving to the next record is usually more CPU/RAM friendly (you can work on stuff while the next chunk is still coming off disk, and while the last chunk is still going to disk). Trying to count the number of IO calls you make is entirely short-sighted of your ISP, if that is indeed what they're doing.

As has been mentioned, you can use /(?=\n)/ for your split. In the reverse, you should use join to, well, join them back together. join is the opposite of split:

@test = split /\n/, $rec; # ... work ... $rec = join "\n", @test;
In this case, you are splitting (and thus removing) \n's. In the next case, based on Roy Johnson's advice, you are removing nothing, so you join with nothing:
@test = split /(?=\n)/, $rec; # ... work ... $rec = join '', @test;
Hope that helps.


In reply to Re: Suggestions for optimizing this code... by Tanktalus
in thread Suggestions for optimizing this code... by NeilF

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.