M
Mark
I am reading piped output from a command that produces a lot of
output. I would like to terminate reading the data before the end of
the output is reached.
The following sample program illustrates the issue. The program will
get stuck on the close(). Any help in dealing with this situation
will be appreciated.
I am having this issue on Windows XP.
use strict ;
use warnings ;
$| = 1 ;
# The following one line perl program produces the lines, "one",
"end", "two",
# continuously, forever.
# Note: You may need to change the quote characters for your command
shell.
my $GenTxtCmd = 'perl -le "while () {foreach (qw(one end two))
{print};}" ' ;
open my $FH, '-|', "$GenTxtCmd" or die "open failed: $!" ;
while (<$FH>) {
print "got $_" ;
last if /end/ ;
}
print "performing close()\n" ;
my $result = close($FH) ;
print "completed close(), result=$result\n" ;
output. I would like to terminate reading the data before the end of
the output is reached.
The following sample program illustrates the issue. The program will
get stuck on the close(). Any help in dealing with this situation
will be appreciated.
I am having this issue on Windows XP.
use strict ;
use warnings ;
$| = 1 ;
# The following one line perl program produces the lines, "one",
"end", "two",
# continuously, forever.
# Note: You may need to change the quote characters for your command
shell.
my $GenTxtCmd = 'perl -le "while () {foreach (qw(one end two))
{print};}" ' ;
open my $FH, '-|', "$GenTxtCmd" or die "open failed: $!" ;
while (<$FH>) {
print "got $_" ;
last if /end/ ;
}
print "performing close()\n" ;
my $result = close($FH) ;
print "completed close(), result=$result\n" ;