I highly doubt that. Very highly doubt it. Try using a data-dumping module to spit out exactly what you have. For example:
or, if you don't have JSON:$ perl -MJSON -le '$output=`./asdf`; print encode_json([$output])' output to stderr ["output to stdout\n"] $ perl -MJSON -le '$output=`./asdf 2>&1`; print encode_json([$output]) +' ["output to stdout\noutput to stderr\n"]
You'll notice that if you omit the 2>&1, the stderr part shows up outside of the variable being dumped. What's more, it shows up first, which your original code shows is not what is happening for you. The only way that the stderr shows up after the stdout, given your asdf program, is if the stderr is successfully caught.$ perl -MData::Dumper -le '$output=`./asdf`;print Dumper $output' output to stderr $VAR1 = 'output to stdout '; $ perl -MData::Dumper -le '$output=`./asdf 2>&1`;print Dumper $output' $VAR1 = 'output to stdout output to stderr ';
I will now ask you to take back you "bad design" call in your updated original node. It is based on your flawed testing, which your own node shows to be flawed. If you want to understand why the order of the output would be different if you weren't catching stderr, I would suggest a new root-level node for that. Not because we can't answer it here, but because I think you should go back to your test code and play with it for some time to see if you can figure it out yourself (with the help of google, that's fine) before asking.
In reply to Re^3: backticks fail to capture stderr even with explicit redirection
by Tanktalus
in thread backticks fail to capture stderr even with explicit redirection
by keithhanlan
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |