For anybody who is interested, my final decision is now to implement my own pattern scanner (based on a state machine) which operates directly on the source files without using Perl's regular expression engine. I am not yet sure if I should explicitly operate on chunks or if I should rely on the O/S's buffering layer (which should enable me to read single characters from a file without performance penalty, shouldn't it?).

This approach also has the advantage that I could easily port the application to another programming language (compiler based, perhaps with assembly optimizations). Using an own pattern scanner will make this much more easier.

After having read davido's proposition of using File::Map, I initially hoped that this would be the solution. In the meantime, I have studied the documentation for this module, and if I got it right, it will read the parts of the file which actually get used into memory. Although this will happen lazily (which is a fine technique), it disqualifies the solution for that specific problem: There are enough situations where I could end up with the complete file being in memory which is exactly the thing to be avoided.

Thanks again to everybody who helped!

Nocturnus


In reply to Re: Possible to have regexes act on file directly (not in memory) by Nocturnus
in thread Possible to have regexes act on file directly (not in memory) by Nocturnus

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.