From your question, it looks like you trying to monitor a file that is being continuously appended to by another process, and you want to read the recent changes.
If this is the case, then the simple method of sleeping and then reading to the end of the file may not work, as you find yourself Suffering from Buffering. In short, if you read to the end of the file, and then the other process add more, then your perl process may not see any more unless you re-open the file, as perl will have buffered the contents of the file already.
Instead, can I suggest that you look into using something like File::Tail, which will let you read to the end of the file, and then block until more data is added. Each time the other process adds more lines to the file, your process will unblock and read it, and so is able to process the new data immediately and reliably.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|