"Changes to the array are reflected in the file immediately."

Note that the Tie::File docs do not say here (or anywhere else) that changes to the file will be reflected in the array immediately. Tie::File may be capable of following additions to a ever-growing file, but that really doesn't appear to be one of the tasks it was designed to handle.

A couple more relevant bits from the locking section of the Tie::File docs are

When you use flock to lock the file, Tie::File assumes that the read cache is no longer trustworthy, because another process might have modified the file since the last time it was read. Therefore, a successful call to flock discards the contents of the read cache and the internal record offset table.

and

The best way to unlock a file is to discard the object and untie the array.

To me, these indicate that, if the underlying file is changed, then Tie::File will have to rebuild its table of record offsets, which means starting over from the beginning of the file and reading every line until it reaches the one you're looking for (i.e., the one that was just added to the end of the file), which is exactly the sort of re-scan we're trying to avoid here.


In reply to Re^2: Parse Log File As Written by dsheroh
in thread Parse Log File As Written by alanonymous

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.