Skeeve has asked for the wisdom of the Perl Monks concerning the following question:
Maybe it's something very obvious to anyone but me? ;)
I want to analyze an external program's STDOUT and STDERR and don't like to redirect STDERR to a file which I later have to read, and delete.
So I thought I'd redirect STDERR to a variable like this:
close STDERR; open STDERR,">",\$x or die; `ls /some/nonexisting/path`; print $x;
I expected $x to read "/some/nonexisting/path: No such file or directory" but it's simply empty.
Does anyone of you see what's wrong and can give me a hint?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Can't capture STDERR to Variable
by moritz (Cardinal) on Jul 21, 2011 at 10:18 UTC | |
|
Re: Can't capture STDERR to Variable
by salva (Canon) on Jul 21, 2011 at 10:21 UTC | |
|
Re: Can't capture STDERR to Variable
by davido (Cardinal) on Jul 21, 2011 at 10:22 UTC | |
|
Re: Can't capture STDERR to Variable
by zentara (Cardinal) on Jul 21, 2011 at 11:41 UTC | |
by ikegami (Patriarch) on Jul 21, 2011 at 19:31 UTC | |
|
Re: Can't capture STDERR to Variable
by Skeeve (Parson) on Jul 22, 2011 at 07:11 UTC |