in reply to Suggestions for optimizing this code...

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.

Replies are listed 'Best First'.
Re^2: Suggestions for optimizing this code...
by NeilF (Sexton) on Jan 17, 2006 at 10:23 UTC
    Is there not a way to not use $rec and instead to split the record up within the sysread itself? eg: Something akin to:-

    sysread(DF, split(/(?=\n)/,$[0]), -s DF);

    I'm sure that's jibberish, but you get the idea...