I did a PM search on sysread and came up with a few nodes, one of which may be relevant to your problem (as VSarkiss pointed out, sysread is probably the best solution): EEK! sysread() is expensive!.

You might want to use a multiple of 150 that is closest to 4096, or 4050 (27, 150 byte chunks), and you may be able to reduce some of the associated overhead. Although you'll still need to break it up into 150 byte chunks, you could modify one of the regex solutions provided for that purpose.

A benchmark would be interesting, since I don't know if the gain in speed by increasing the block read might be cancelled out by the additional processing required to break up the 4050 byte string. Unfortunately, I'm at work right now and don't have time to try it myself.

--Jim


In reply to Re: Long string needs to be separated by jlongino
in thread Long string needs to be separated 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.