[Chicago-talk] How to make readline <> block on pipe.

Jon Amundsen jamundsen at jamundsen.dyndns.org
Fri Sep 23 08:18:33 PDT 2005

Hi All!

Does anyone know how to make the <> operator or readline block until there is data?  I am trying to read from a pipe, and would like it to block until more data arrives.

Here is a simple example:

open(APIPE, "<./pipe") || die $! ;	### the open *does* block

while(1) {

	my $line = <APIPE> ;		### if there's nothing on the pipe this doesn't wait.
	print "line is: ", $line, "\n" ;
	sleep 1 ;			### just so it doesn't spin too fast during testing


I've tried using IO::File also and the ->blocking() method, but as far as I can tell it behaves the same.  Any help is really appreciated.


Jon Amundsen
jamundsen at jamundsen.dyndns.org

A "No" uttered from deepest conviction is better and greater than a
"Yes" merely uttered to please, or what is worse, to avoid trouble.
                -- Mahatma Gandhi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://mail.pm.org/pipermail/chicago-talk/attachments/20050923/e36d22d9/attachment.bin

More information about the Chicago-talk mailing list