jeanluca has asked for the wisdom of the Perl Monks concerning the following question:
This will make sure that everything printed by $module is redirected to $out.my $module = MyModule->new() ; ... my $out = '' ; { local *STDOUT ; local *STDERR ; open (STDOUT,">>", \$out) ; open (STDERR,">>", \$out) ; $module->process() ; } ....
Everything printed by some_prog is now redirected to $out and not to @prog_out. Any suggestions how to fix this ?use IPC::Open2 ; .... sub process { .. my $pid = open2( *Reader, *Writer, "some_prog" ); print Writer "$some_options" ; my @prog_out = <Reader> ; close Writer; close Reader; .. return @output ; }
I've fixed this and now I can doprint STDOUT "....." ;
Thnx!!open OUT,">>", \$out ; select OUT; $| = 1 ;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Problem with IPC::Open2 when STDOUT/STDERR are redirected (!local)
by tye (Sage) on Feb 28, 2008 at 16:10 UTC | |
by Zaxo (Archbishop) on Feb 29, 2008 at 11:09 UTC | |
by tye (Sage) on Feb 29, 2008 at 15:41 UTC | |
|
Re: Problem with IPC::Open2 when STDOUT/STDERR are redirected
by pc88mxer (Vicar) on Feb 28, 2008 at 14:20 UTC |