By has no effect what do you mean? With the reader loop as written, on Win32, without the 0x1a it gets both lines, then hangs (blocks), awiating EOF. With the 0x1a it detects the end of the input and then finishes. Tested on Win2k SP2, AS perl 5.6.1

To get it to run as written on Linux (CentOS) perl 5.10 you need to close $wtr. Sending 0x1a makes no difference.

[james@adajio ~]$ cat cat.pl $|++; print while <>; [james@adajio ~]$ cat ipc.pl #!/usr/bin/perl use strict; use IPC::Open2; $|++; my $EOF = ''; # chr(0x1a); # inline use "\x1a" my $perl = "/usr/bin/perl"; my $cat = "/home/james/cat.pl"; my $data = "first line\nsecond line"; my $pid = open2(my $rdr, my $wtr, $perl, $cat ); print "Sending:\n$data\n----\n"; print $wtr $data .$EOF; close $wtr; print "Going for read!\n"; print while <$rdr>; [james@adajio ~]$ ./ipc.pl Sending: first line second line ---- Going for read! first line second line [james@adajio ~]$

So on linux the act of closing $wtr effectively sends the EOF signal. Physically sending apparently does nothing. Sending a \n at the end of the $data string allows reading of the second line but it still hangs awaiting EOF. Thus a portable way of doing it is to send the EOF (makes it work on Win32) and close $wtr (makes it work on *nix) - as this ensures perl gets a detectable EOF into the $rdr stream.


In reply to Re^3: ActiveState woes : Is it EOF-blind? by tachyon-II
in thread ActiveState woes : Is it EOF-blind? by rovf

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.