Greetings, esteemed monks! I am trying to write a program which will print a line of input that it reads from a named pipe. As each new line of input appears on the pipe, I want my program to send it to stdout. Not sure if it is relevant, but this is on FreeBSD. Here is the code I am using:
use FileHandle; $tmpfile = "/var/tmp/fifotest"; open (FIFO, "$tmpfile"); STDOUT->autoflush(1); FIFO->autoflush(1); print <FIFO>; close (FIFO);
However, when I write to my named pipe with another program, output will not appear from my perl script above until I send an EOF to the pipe. I ran truss on my perl script, and I see it reading in the data as each line is fed to the pipe, but it doesn't do any writing until the EOF goes to the pipe from the other program which is writing to the pipe. Is this due to some kind of buffering issue? Any way to accomplish this? Thanks!

In reply to line by line reading named pipes by jiemi

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.