in reply to Re: Is it possible to use the open( ) function with piped unix commands?
in thread Is it possible to use the open( ) function with piped unix commands?

On perl's side, closing the file handle flushes the data and releases the process (does a waitpid).

On sort's side, the closed input tells sort it's done receiving data so it can proceed to sort and print it.

Replies are listed 'Best First'.
Re^3: Is it possible to use the open( ) function with piped unix commands?
by Joost (Canon) on Jul 19, 2007 at 15:31 UTC
    Yes, but I assumed that perl would close F at end of script, flushing the buffers. Instead, without the close() statement, the program just waits.

    After some more testing, it appears that I got confused. Perl does close the pipe when you don't do it yourself, but the output is printed just after the new prompt. (which is why i got confused)

      Thanks to all for the great feedback.
      It was really appreciated.