Programming Perl

Programming PerlSearch this book
Previous: 3.2.106 packageChapter 3
Functions
Next: 3.2.108 pop
 

3.2.107 pipe

pipe READHANDLE, WRITEHANDLE

Like the corresponding system call, this function opens a pair of connected pipes - see pipe(2). This call is almost always used right before a fork, after which the pipe's reader should close WRITEHANDLE, and the writer close READHANDLE. (Otherwise the pipe won't indicate EOF to the reader when the writer closes it.) Note that if you set up a loop of piped processes, deadlock can occur unless you are very careful. In addition, note that Perl's pipes use standard I/O buffering, so you may need to set $| on your WRITEHANDLE to flush after each output command, depending on the application - see select (output filehandle).

See also the section on "Pipes" in Chapter 6.


Previous: 3.2.106 packageProgramming PerlNext: 3.2.108 pop
3.2.106 packageBook Index3.2.108 pop