awohld has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl -w use strict; my ( $form, $clone_from, $clone_to ) = @ARGV; # Trying to use this to capture output open( STDOUT, "|-" ) or die ("Can't open standard output: $!\n"); open( my $writeme, "| program -text -brief clone_error") or die ("Can't run write program: $!\n"); print $writeme <<EOF; $form r clone_from=$clone_from r EOF # Program works fine for write, and at this point a bunch of text is +printed from the program # to the screen. But I want to capture the output to a variable. # This was my try but it doesn't work my $output; while ( <STDOUT> ) { $output .= $_; } print "stored " . $output . " stored";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Reading programs output into a Scalar - How?
by Joost (Canon) on Dec 15, 2006 at 20:18 UTC | |
|
Re: Reading programs output into a Scalar - How?
by jettero (Monsignor) on Dec 15, 2006 at 22:58 UTC | |
|
Re: Reading programs output into a Scalar - How?
by xorl (Deacon) on Dec 15, 2006 at 20:47 UTC | |
|
Re: Reading programs output into a Scalar - How?
by zentara (Cardinal) on Dec 16, 2006 at 13:16 UTC |