Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Two questions:
test script#!perl -w print <<EOF; Line one line two line three EOF
Results in:use IO::Handle; use IPC::Open2; open FH, "perl test.pl|" or die $!; while (<FH>) { chomp; print "test1:[$_]\n"; } close FH; my ( $rdrfh, $wtrfh ); my $pid = IPC::Open2::open2($rdrfh, $wtrfh, 'perl','test.pl' ); while (<$rdrfh>) { chomp; print "test2:[$_]\n"; } open FH, "perl test.pl|" or die $!; my $fd = IO::Handle->new_from_fd( fileno(FH), "r" ); while ( <$fd> ) { chomp; print "test3:[$_]\n"; }
I know I can solve this with:C:\WINDOWS\Desktop>perl t.pl test1:[Line one] test1:[line two] test1:[line three] ]est2:[Line one ]est2:[line two ]est2:[line three test3:[Line one] test3:[line two] test3:[line three]
But is reading in binary mode expected behavior?binmode $rdrfh, ':crlf';
Another question is why I cannot specify "rb" as the MODE above.
Thanks,
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Binmode and IPC::Open2
by liz (Monsignor) on Jul 29, 2003 at 23:06 UTC | |
by Anonymous Monk on Jul 30, 2003 at 00:52 UTC |