How big are the files? How many searches are going to be done vs how many updates to the files? If there are going to be many searches and few updates, I'd personally run them through a parser first and eliminate non-word characters and dead space, then lowercase what's left and save to copies of the original files. Then the copies are what I'd search for the keywords. If the files are under say 20 MB and there are going to be lots of searches, I could load each file into memory in its entirety instead of line by line, and assuming I only cared about whethere the keywords were present in the file or not, I could use index (since I lowercased) rather than regex, which is significantly slower with the i flag on.

I don't know what you're doing, but it's the wrong approach.


In reply to Re: acessing the contents of a file character by character by TedPride
in thread acessing the contents of a file character by character by gvs_jagan

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.