Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

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.

In reply to Re: how to read every 10 line from input text file ? by chrestomanci
in thread how to read every 10 line from input text file ? by bh_perl

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • 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.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (7)
As of 2023-03-27 10:03 GMT
Find Nodes?
    Voting Booth?
    Which type of climate do you prefer to live in?

    Results (63 votes). Check out past polls.