in reply to Pipe autoflush

I think your problem is that you're reading from SAPR in list context (because of the print), so it's trying to read too much, and thus blocks...  Try

print scalar <SAPR>;

or

my $sap_line = <SAPR>; # scalar context print $sap_line;

In that case you don't have to close SAPW.

Replies are listed 'Best First'.
Re^2: Pipe autoflush
by Zielony (Acolyte) on Aug 23, 2007 at 12:37 UTC
    Works. Thank you very much!

    UPDATE

    ...but only for cat. For other programs, for example md5sum, not.

      Smooth communication depends on both sides agreeing on a common protocol. Not all programs operate in a line based fashion like cat. For example, if you're having md5sum read its data from stdin (instead of supplying a list of filenames), it is reading the entire input (which may include newlines), then prints the digest of that data to stdout, and quits. IOW, simply replacing cat with md5sum in the code above can't work.

      If you let us in on what you're ultimately trying to achieve, we might be able to provide better assistance... :)

        I want to make API for SAP, Polish-English/English-Polish translator. It works in such way:
        zielony:~$ sap -a # green # typed by me Slownik angielsko-polski green - rzeczownik zielen, trawnik przymiotnik zielony greens - liczba mnoga warzywa grow green - zazielenic sie -p # zielony # also by me Slownik polsko-angielski zielony - przymiotnik green